Cannot load file or assembly System.Runtime

1

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.

c#
.net
nuget
visual-studio-2017
asked on Stack Overflow Oct 27, 2017 by g.arbia777

4 Answers

4

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.

answered on Stack Overflow May 25, 2018 by Rahul Shete • edited May 25, 2018 by Neuron
2

I resolved the issue myself. I recreated both projects, targeting .NET 4.7, and the issue was resolved.

Maybe the problem was that I originally targeted an earlier version of .NET and then changed the version. But I am not sure.

answered on Stack Overflow Oct 27, 2017 by g.arbia777
2

I had faced the same issue. Just follow these steps to solve your problem

  • Right Click on your solution and choose Manage NuGet Packages for Solution
  • In the Installed tab search System.Runtime
  • Now you can see in which projects you have installed the library
  • Select proper projects and downgrade System.Runtime to the previous version and upgrade it again
  • Clean & Rebuild your solution
  • Run project

It should works now.

answered on Stack Overflow Feb 7, 2019 by Masoud Darvishian • edited Feb 7, 2019 by Masoud Darvishian
0

In my case, my WPF executable started crashing when I made a Grpc call. It turns out the project's app.config file contained some assembly bindings left over from IDK what (VS 2019 16.3 update? NuGet update?). After I deleted them, it worked again.

Exception

System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Source=System.Memory StackTrace: at System.SpanHelpers.PerTypeValues'1.MeasureArrayAdjustment() at System.SpanHelpers.PerTypeValues'1..cctor()

Inner Exception 1: 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.


App.config

Delete these bindings:

<dependentAssembly> <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly>

answered on Stack Overflow Sep 28, 2019 by skst

User contributions licensed under CC BY-SA 3.0