I am just starting out with .NET standard. In a proof-of-concept project I'm trying to use Dapper as my ORM. In the .NET Standard 2.0 class library project, I added Dapper 1.50.5 Nuget package. However, the assembly isn't getting loaded at runtime. I get this error:
System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'Dapper, Version=188.8.131.52, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Complete contents of my .csproj:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netstandard2.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Dapper" Version="1.50.5" /> <PackageReference Include="Npgsql" Version="4.0.4" /> <PackageReference Include="System.Data.SqlClient" Version="4.6.0" /> <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" /> <PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.1" /> <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" /> <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.1" /> </ItemGroup> </Project>
So, you see I've installed the dependencies and dependencies of the dependencies.
What else should I do?
The .NETStandard assembly was added as a reference to my WPF project. I needed to make changes in the .csproj of the WPF project.
The solution mentioned in https://github.com/dotnet/sdk/issues/901 fixes it.
Add the below two lines in each that you find in it.
User contributions licensed under CC BY-SA 3.0