I am trying to create a .Net Standard 2.0 library (I am using visual studio 22)I encountered the following problem while running the project:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
This is my .csproj file:
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>netstandard2.0</TargetFramework><OutputType>Exe</OutputType> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies><AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects></PropertyGroup><ItemGroup><PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" /><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" /><PackageReference Include="Newtonsoft.Json" Version="13.0.3" /><PackageReference Include="RestSharp" Version="106.15.0" /><PackageReference Include="Serilog" Version="4.0.0" /><PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" /><PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" /><PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /></ItemGroup></Project>
There were a lot of problems with the packages, so I added the line:
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
But it only solved some of the errors (I downgraded some of the packages to solve other errors) but I was left with the above error.I am new to .net and would really appreciate your help.(And if you ask why .net standrad then it's because I need to produce a package from my code that will fit several different versions (both core and framework)