Nuget updates install bindingRedirects for system.runtime, which then fail at runtime

I have a moderately complex application with a unit test project targeting the .NET Framework 4.6.1

If I run the following package management console:

update-package -reinstall -project velogicfit.Sizer3D.Core.UnitTests

... then Nuget adds a bunch of redirect bindings to the app.config file of the unit test project, redirecting things like System.Runtime to v4.1.1.0:

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

And then, when the project starts (by NCrunch), it crashes with the message:

 System.IO.FileNotFoundException: 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. 

I could fix the error by installing a newer version of the framework, but I would better understand what makes Nuget add these binding redirects.

Looking through each DLL in the unit test project output directory, the highest link I see is system.runtime v4.0.20.0

I tried asmspy and it also reports that there are some dependencies on 4.0.20.0, but nothing on 4.1.1.0

FWIW, links to system.runtime v4.0.20.0 are all of my other projects in the solution, which are aimed at NETStandard 1.4

Questions:

  • How to find out which version of the framework version corresponds to each of these versions of system.runtime (4.0.0.0, 4.0.20.0, 4.1.1.0)?
  • Are there any entries that I can turn on to find out what Nuget thinks, and why does he set the assembly binding forwarding to 4.1.1.0?
  • Should my NETStandard 1.4 projects refer to 4.0.20.0?
+5
source share
1 answer

I decided to solve this problem (and some other problems) by switching to Paket. The package helped me gain control over my direct and transitive dependencies, and then I was able to see what depends on what and how to configure the binding redirection correctly.

+1
source

Source: https://habr.com/ru/post/1268790/


All Articles