0

I have a "Dll Hell" problem. In various projects inside my solution I installed System.Net.Http 4.3.3 package, this one also install System.IO 4.3.0 and System.Runtime 4.3.0 packages as dependencies but the application does not load the correct version of this assemblies. In the Web.config file I have this binding redirects:

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
  </dependentAssembly>    
<dependentAssembly>
        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
      </dependentAssembly>

But in runtime the application loads version 4.0.0.0 of all assemblies. I tried to find the problem in assembly load logs but I don´t find any useful info inside of them. For example for System.Net.Http assembly log is:

*** Assembly Binder Log Entry  (10/01/2019 @ 3:03:33 p.m.) ***
The operation was successful.
Bind result: hr = 0x0. La operación se completó correctamente.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Program Files\IIS Express\iisexpress.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///%ProjectPath%
LOG: Initial PrivatePath = %ProjectPath%\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\vs\8b39e507
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\vs\8b39e507
LOG: AppName = 73c96623
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: %ProjectPath%\web.config
LOG: Using host configuration file: %UserFolderPath%\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Binding succeeds. Returns assembly from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\vs\8b39e507\73c96623\assembly\dl3\3c60a4ed\001138c2_8026d301\System.Net.Http.dll.
LOG: Assembly is loaded in default load context.

I have tried to update all nuget packages to find some old dependency that needs 4.0.0.0 version but the application always load the wrong version.

Uninstalling and reinstalling nuget packages is not an option, main project has up-to 90 package references.

I thought the problem was caused by an .Net3.5 reference in the project, but deleting this I get the same problem.

Thanks

  • When you say you installed, you mean from nuget? Remove that reference, and instead add it from an assembly reference instead. Make sure you remove the existing redirects when you do. – Ben Jan 10 '19 at 21:57
  • @Ben yes, all packages are installed from nuget, and remove all references is not an option. The solution has 14 projects and the packages are dependencies from another package. – Andres Bernal Jan 11 '19 at 00:00
  • Not all references, just the System.Net.Html one. https://stackoverflow.com/questions/47149345/could-not-load-file-or-assembly-system-net-http That includes some possible workarounds and the last answer in particular explains the likely problem. I've had this a couple of times, and this has fixed it both time. – Ben Jan 11 '19 at 00:05

0 Answers0