I am using Visual Studio 2017 and am trying to create a .Net Standard 1.5 library and use it in a .Net 4.6.2 nUnit test project.
I am getting the following error...
If it's working previously, then there should be an App.config change. Undo App.config worked for me.
I had a project with the same problem , I solved it with change dotnet core version from 2.2 to 2.0, If your problem has remained , Try this solution
I'm using ASP.Net CORE 2.1 and I got this error when I ran by selecting a .csproj from a list of about 40 in a big repo. When I opened the csproj file individually, the error was resolved. Something with how the program was launched was different when the csproj was opened.
Into app.config or web.config add
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
I have also gone through this error and sharing how i got rid off to it.
In my case below line existed in web.config of webapi project but there was not package reference in package.config file.
Code in Web.config in Webapi Project
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.3.0" />
</dependentAssembly>
Code I Added in packages.config file in web api project Before closing of element.
<package id="System.Runtime" version="4.3.0" targetFramework="net461" />
Another Solution Worked in My Case:
Another Sure short that may work in case you copied project to another Computer system that may have little different package versions that you can try changing assembly version to version given in error on website / webapi when you run it. Like in this case as given in question Version needed is '4.1.0.0' so simply try changing current version in web.config to version shown in error as below
Error:
Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies
I solve this issue by switching from .NET 4.7.2 => .NET 4.5.2 and then switch back to 472. So in some cases this error occurs because package manager unable resolve dependences