Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies

前端 未结 25 2417
轻奢々
轻奢々 2020-11-28 22:52

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...

相关标签:
25条回答
  • 2020-11-28 23:43

    If it's working previously, then there should be an App.config change. Undo App.config worked for me.

    0 讨论(0)
  • 2020-11-28 23:43

    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

    0 讨论(0)
  • 2020-11-28 23:44

    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.

    0 讨论(0)
  • 2020-11-28 23:45

    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>
    
    0 讨论(0)
  • 2020-11-28 23:47

    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
    

    0 讨论(0)
  • 2020-11-28 23:48

    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

    0 讨论(0)
提交回复
热议问题