Skip to content

dotnet run fails with System.IO.FileNotFoundException if using local class library #7814

Closed
@alejiro

Description

@alejiro

Steps to reproduce

  1. Create a console project dotnet new console -n MyConsole
  2. Create a class library project dotnet new classlib -n MyClass
  3. Reference class library project in the console project MyConsole.csproj file using:
<ItemGroup>
    <Reference Include="MyClass">
       <HintPath>path_to_library/MyClass.dll</HintPath>
    </Reference>
 </ItemGroup

4.Use MyClass in MyConsole

using System;
using MyClass;

namespace MyConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(MyClass.HelloWorld);
        }
    }
}
  1. Run MyConsole application dotnet run

Expected behavior

Application executes

Actual behavior

Application crashes with:

Unhandled Exception: System.IO.FileNotFoundException: 
Could not load file or assembly
'MyClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 
The system cannot find the file specified.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc4-004893)

Product Information:
 Version:            1.0.0-rc4-004893
 Commit SHA-1 hash:  ca4d0b8fbb

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.0-rc4-004893

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions