2
votes

I have a solution with over 40 projects. In most of these projects I'm using System.Net.Http which I have installed via NuGet. At the time of writing we have installed v4.3.3 from Nuget. That is also what is written into packages.config

<package id="System.Net.Http" version="4.3.3" targetFramework="net47" />

When I look into my app.config , I'm using different versions here. In some of my configs the version is listed as 4.1.1.2, in others its listed as 4.2.0.0. I Guess these are the internal versions, but what I find wired is that installing the same NuGet on two different projects gives me two different internal versions.

One app.config:

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

Another app.config:

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

I have tried downgrading and then upgrading again in Nuget in order to get both the packages.config & app.config updated. And the files are updated. But in some app.config I get another version than I get in other. With the excat same NuGet version, installed at the same time.

What gives?

I have read quite a bunch of topics here on SO, but none of them quite has the same problem. Most of the time, people fix their problem by upgrading to the latest version, that doesn't help here.

I'm guessing that I might have other references that force the version of System.Net.Http to an older version for that project, but is there any way I can confirm this thesis? Also, if that is actually the case, is it then possible to enforce all project to run the highest common version instead of different versions?

1

1 Answers

0
votes

Found conflicts between different versions of the same dependent assembly - app.config different from packages.config

It seems that Visual Studio 2017 is shipping with a .NET 4.6.x-4.7.x System.Net.Http.dll with internal assembly version 4.2.0 and the latest Nuget Package assembly version is 4.1.2 for NetFX.

The author of this package Microsoft needs to release an updated nuget package with a version of 4.2.0.0.

The current workaround is probably change the bindingRedirect 4.1.1.2 to 4.2.0.0:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
  </dependentAssembly>      
</assemblyBinding>

In this case, all the dlls are used from the build extensions directory and not the one from Nuget.

Hope this helps.