Found conflicts between System.Net.Http

前端 未结 9 1392
一整个雨季
一整个雨季 2020-12-08 07:12

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

相关标签:
9条回答
  • 2020-12-08 07:31

    I've had this problem twice now whilst working with Azure Worker roles. Any called to system.net.http simple causes the code to hang, but there is no feedback at all from Azure so it takes hours or days of commenting out code to find the cause let alone a solution.

    A simple trick fixed it for me. This isn't my solution, I came across it about 6 months ago, but when the problem happened to me again today, I thought it worth posting.

    1. Delete any references to System.Net.Http from your project
    2. Go to "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib"
    3. Create a new directory, for example "temphide"
    4. Move all System.Net.* DLL's into this directory
    5. Now when you deploy, your project will use the Nuget version, no more conflicts
    0 讨论(0)
  • 2020-12-08 07:36

    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

    0 讨论(0)
  • 2020-12-08 07:40

    I am working with .NET 4.6.2 and found the same problem. I have two projects a web site and a test project. I review the following:

    • Both project has installed the NuGet package for System.Net.Http

    • The references in both program are equal and both point to the same
      package

    The Problem. The Web.Config and the App.Config from the project point to different System.NET.Http.

    I substitute the code in both config to get:

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

    in both of them. Then the conflict disappear.

    0 讨论(0)
提交回复
热议问题