Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't use the System.Runtime 4.3.0 in a .net 4.7 project

I have a .net 4.7 project which has installed the version 4.3.0 of System.Runtime. But when I run the project I get an exception that say that it can't be found the version 4.1.0.0.

If I go to the nuget manager, I install the version 4.1.0.0 in the project, then it works. So I have tried to update again to the version 4.3.0, but again, I get the problem.

The project was working until now, really I don't know why it stops to work because I don't touch anything related with the nuget packages.

Also I have tried to created a new empty solution and add the project, to try a fresh solution, but the problem is the same.

How could I solve the problem?

Thanks.

like image 224
Álvaro García Avatar asked Jun 14 '17 16:06

Álvaro García


1 Answers

NuGet should generate the necessary binding redirects into the App.config for packages.config based projects or set AutoGenerateBindingRedirects to true for csproj files using PackageReference to reference NuGet packages.

If for some reason this did not happen or you are using the libraries from a different project / application, it may be necessary to add the binding redirect manually to the app.config / web.config file:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <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>
    </assemblyBinding>
  </runtime>
</configuration>
like image 174
Martin Ullrich Avatar answered Oct 01 '22 05:10

Martin Ullrich