Found conflicts between System.Net.Http

I have several projects in my VS solution. Whenever I add "System.Net.Http" NuGet package to one it shows as version 4.2.0.0. Then I do the same and add same NuGet Package, however, the other says version. 4.1.1.2

Then I get a warning:

Found conflicts between System.Net.Http

EDIT1:

Gathering dependency information took 1.7 sec
Attempting to resolve dependencies for package 'System.Net.Http.4.3.3' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'System.Net.Http.4.3.3'
Resolved actions to install package 'System.Net.Http.4.3.3'
Retrieving package 'System.Net.Http 4.3.3' from 'nuget.org'.
Adding package 'System.Net.Http.4.3.3' to folder 'C:\...Service\packages'
Added package 'System.Net.Http.4.3.3' to folder 'C:\...Service\packages'
Added package 'System.Net.Http.4.3.3' to 'packages.config'
Successfully installed 'System.Net.Http 4.3.3' to ....Service
Executing nuget actions took 2.05 sec
Time Elapsed: 00:00:03.8937113

Please notice correct version installed, However => Props => Version says 4.1.1.2

Cannot resolve conflicts with System.Net.Http when referencing a , Found conflicts between different versions of "System.Net.Http" that could not be resolved. These reference conflicts are listed in the build log  This project illustrates how referencing a 4.7.2 project from a .net standard 2.0 project where System.Net.Http is involved triggers the following warning on build. Found conflicts between different versions of "System.Net.Http" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

After going through all the solutions presented here and the references cited in this answer, I finally resolved this completely. This is what I believe anyone who experiences this issue should do:

  1. Update all NuGet packages to latest.
  2. Migrate NuGet from packages.config to PackageReference as per the instructions here. Basically, for each project in your solution, In Solution Explorer, right-click on the References node or the packages.config file and select Migrate packages.config to PackageReference.... ASP.NET website projects must remain using packages.config.
  3. Remove any references to System.Net.Http that are not managed by NuGet (for projects using PackageReference, you should see the NuGet symbol next to the reference in Solution Explorer). Replace the removed System.Net.Http references with the corresponding NuGet package if you're certain your project requires System.Net.Http (try building without it first). For projects using packages.config, take extra care to ensure that references to System.Net.Http are required and that they are also using NuGet. It may help to remove and re-add System.Net.Http via NuGet anyway (for all projects referencing it), even if already referenced using NuGet. I found that step 2 can cause some disjoint somewhere.
  4. Upgrade to .NET Framework 4.7.2 for the reasons described here. This is part of VS 2019. Otherwise, download it from here or use the Visual Studio Installer for VS 2017.
  5. Remove all the assembly bindings from all app.config and Web.config files then build your solution. app.config bindings are not required anymore. Web.config bindings will be re-added in the next step, but removing them first ensures you don't have any outdated versions in your bindings.
  6. You may now get some other conflicts at this stage. For your ASP.NET website projects, add the binding redirects to your Web.config that are given to you in the warnings. For other .NET Framework applications, for the references that you are getting warnings for, add the corresponding NuGet packages in the projects where you are getting the warnings, even if the project compiles without the reference being added. This forces the project to use the NuGet version and not the local .NET Framework version that might be getting referenced by another package. This is due to cross-over between .NET Framework and .NET Standard as alluded to by rsenna's aforementioned answer. After building, you may need to repeat this step for further references.

If you later find that you get run-time exceptions (even during unit testing) due to manifest mismatches after adding a reference somewhere, remove all the binding redirects from the website project concerned, then re-add the suggested ones given in the warning as per step 6.

I spent a lot of time trying to resolve this issue methodically, so I believe the above steps would fully resolve most people's issues, although some lateral thinking might be required for unusual cases. Let me know if this works (or doesn't work) for you.

Found conflicts between different versions of "System.Net.Http" that , Found conflicts between different versions of "System.Net.Http" that could not be resolved - in Xamarin Android #117. Closed. However, nowhere I can find the exact version number of System.Net.Http. Finally, I used ILSpy to inspect Microsoft.Rest.ClientRuntime and it seems to depend on System.Net.Http in version 4.0.0.0. I have also tried removing all references to System.Net.Http and installing the newest NuGet (4.3.2). That lead to subsequent errors with missing

This tends to happen when you have a reference to the framework System.Net.Http, but one of your package references requires the NuGet package System.Net.Http.

See if you have a reference to that assembly, remove it and install the NuGet package instead

Solving: Found conflicts between different versions of the same , Found conflicts between different versions of the same dependent assembly. The was caused by the referenced assembly System.Net.Http. Doing that kind of binding redirect is the correct workaround to this problem. However, you should just bind back to the 4.0.0..0 version. Doing so will ensure you use the GAC'd version of System.Net.Http.dll from the .NET Framework and not use the System.Net.Http.dll binary from the NuGet package. < runtime > < assemblyBinding xmlns = "urn

You can force the version you're installing, so you can have both projects aligned or find a message in the output window, which would be telling you what's wrong or what your dependencies are. Since the official link lists no 4.2 release, I would do this (solution-wide)

Install-Package System.Net.Http -Version 4.1.1

Or for both projects

Get-Project ProjectName | Install-Package System.Net.Http -Version 4.1.1

Or, even better (using the last version)

Install-Package System.Net.Http -Version 4.3.3

EDIT

Apparently you are not the first to experience this. How about the answer here? Basically you can align this section of both projects config file:

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

You might have to adapt the token value. Just in case, could you paste the config file for both projects=

How do I avoid different versions of an assembly in my App , 2> Consider app.config remapping of assembly "System.Net.Http warning MSB3277: Found conflicts between different versions of the same  Found conflicts between different versions of the same dependent assembly that could not be resolved Hot Network Questions Why is the Nintendo Entertainment System (NES) referred to as an 8-bit system, rather than a 1-byte system?

There is a new solution to this that works as of the 9th of October 2018.

  1. You will need to update all your references to System.Net.Http to the latest version 4.3.4.
  2. You should install the package into your .Net framework solution that is causing the conflict, even if it does not explicitly require the package.
  3. If your project has the new project structure, edit it and make sure it includes the following package reference:

    <PackageReference Include="System.Net.Http" Version="4.3.4" />
    
  4. Search your solution and delete any existing binding redirects for System.Net.Http they will look as follows

    <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>
    
  5. Rebuild, the warning should now be gone and your code should build and run fine

Deployment Failure Because of System.Net.Http Version Differences , targets(2110,5): warning MSB3277: Found conflicts between different versions of "System.Net.Http" that could not be resolved. These  I was getting the warning: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1546,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. The was caused by the referenced assembly System.Net.Http.

How to resolve .NET reference and NuGet package version conflicts , Http v4.5. We also reference project B with NuGet which references System.Net.​Http v4.0. This phenomenon is knows as NuGet Hell. The result  - In Visual Studio, create a new Xamarin.Android app - Add a reference to the Microsoft.Net.Http NuGet package (currently version 2.2.28) - Build project EXPECTED: No errors or warnings ACTUAL: Warnings about version conflicts for System.Net.Http DLL in build output: 1> Consider app.config remapping of assembly "System.Net.Http, Culture=neutral

22670 – Build warnings after referencing Microsoft.Net.Http NuGet , Common.targets(602,3): warning MSB3247: Found conflicts between Net.Http.​Extensions.dll assembly wants System.Net.Http.dll v1.5.0.0:  Found conflicts between different versions of "System.Net.Http" that could not be resolved. There is no way to solve it by using binding redirects as far as I can tell. Project: Visual Studio 2017 15.9.7 Xamarin 4.12.3.80 Serilog.Sinks.Seq 4.0.0 Targetting Android 8.1 Oreo. Repro:

System.Net.Http reference conflict possibly due to .NET Standard 2.0 , NET project I can see Found conflicts between different versions of "System.Net.​Http" that could not be resolved. Furthermore, when making a call to HttpClient. The explicit binding redirect on "System.Net.Http, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" conflicts with an autogenerated binding redirect. Consider removing it from the application configuration file or disabling autogenerated binding redirects.

Comments
  • Are the projects targeting the exact same framework version?
  • yes. all are 4.6.1
  • Is it likely you've got something which depends on 4.1.1.2 in the project that Nuget is pulling that version for? Worst case you can just install 4.1.1.2 in the other project using the -Version command line option
  • I uninstalled ALL nuget packages, removed all refereces from other projects. Then Added System.Net.Http NuGet again. Still says 4.1.1.2.
  • I've noticed that this happens when you create a new service fabric Stateful project. The target framework says 4.6.1. When you add "System.net.http"NuGet to that project it will reference .net.http ver 4.1.1.2. However, when you add a new Class Library, targeting the same .net frawork (4.6.1) and perform the same steps of adding the same NuGet package (System.Net.Http). It will reference ver 4.2.0.0. Not sure how to fix this
  • This has solved my issue. I had a mix of .NET framework and aspnetcore projects running together.
  • This resolved the issue for me as well. Holy jeebus Microsoft .net core team, this is a mess.I spent nearly 2 days trying to solve this on a large project that introduced .net standard libraries.
  • I've added an answer that I based on information I found in this answer and the cited references that shouldn't require to add a random reference like System.Buffers. It's more long-winded, but hopefully it will help.
  • Really frustrating issue with a really unconventional workaround, but I appreciate you figuring this out and sharing it. This solved my issue.
  • This is such a crazy answer I love it.
  • The answer you mentioned seems to indicate that, in order to avoid (most? all?) binding redirects, we need to upgrade to .NET Framework 4.7.2. I found that quite convincing, so +1 for that. But unfortunately I cannot upgrade, at this moment, our environments to 4.7.2, which makes the System.Buffers solution, even if somewhat "random", still the best solution, at least in my case, and at least for now.
  • @rsenna Yes, the requirement to upgrade environments to 4.7.2 is a sticking point for us also, but it's just a matter of kicking off the process and cutting through the red tape as usual. I think it's a better long-term solution than short-term hacks.