C# – Cannot load file or assembly System.Runtime

cnetnugetvisual-studio-2017

I have two projects in one solution. One is a class library that has three nuget packages installed: HtmlAgilityPack, Microsoft.Syndication, and IrcDotNet. The other is the startup project, a console application project with only one Nuget Package installed, Microsoft.Syndication. This project also has a dependency on the class library. When I run the startup project, I get an exception with the following details.

System.IO.FileNotFoundException occurred HResult=0x80070002 Message=Could not load file or assembly 'System.Runtime,
Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or
one of its dependencies. The system cannot find the file specified.
Source= StackTrace: at
AlexiConsole.Program.Main(String[] args) in
c:\Users\myself\documents\visual studio
2017\Projects\Alexi\AlexiConsole\Program.cs:line 21

Inner Exception 1: FileNotFoundException: Could not load file or
assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.

I don't know why. I already have binding redirects in the app.config of both projects for redirecting versions 0.0.0.0-4.1.0.0 to 4.1.0.0.

Both project target .NET 4.7.

Best Answer

I have face same issue, My issue is

System.IO.FileNotFoundException: Could not load file or assembly
'System.Runtime, Version=4.0.20.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.

To Solve this issue, Comment assembly <dependentAssembly></dependentAssembly> which Contain culture="neutral" in Web.config File and Rebuild Application. My application run properly and Problem Solve.