Found conflicts between System.Net.Http

前端 未结 9 1425
一整个雨季
一整个雨季 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:26

    Edit: This happens only when using .NET Framework. In .NET Core/Standard land, the latest System.Net.Http assembly version seems to be always 4.1.2.0 - there is no 4.2.0.0 version available.

    The issue regarding System.Net.Http is way, way more complicated then the answers here seem to imply...

    1. Yes, there is a System.Net.Http NuGet package, but no, it will not install the latest version of the same assembly (it contains version 4.1.1.2 of the System.Net.Http assembly, not 4.2.0.0).
    2. Latest Microsoft Visual Studio (or Microsoft Visual Studio Build Tools) provides version 4.2.0.0, but that does not mean your .csproj will always use it...
    3. For some reason (which I was not able to understand yet), the only guaranteed way of using 4.2.0.0 is by referencing certain NuGet packages that uses it, such us System.Buffers (version 4.5.0 worked for me).

    TL;DR:

    Add System.Buffers 4.5.0+ NuGet reference to your project, if you want to make sure it is using System.Net.Http 4.2.0.0 assembly.

    References:

    • https://github.com/dotnet/corefx/issues/17522
    • https://github.com/dotnet/corefx/issues/22781
    • https://github.com/dotnet/corefx/issues/25773

提交回复
热议问题