发现System.Net.Http之间的冲突 [英] Found conflicts between System.Net.Http

查看:551
本文介绍了发现System.Net.Http之间的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的VS解决方案中有几个项目。每当我将 System.Net.Http NuGet程序包添加到其中时,它就会显示为4.2.0.0版。然后我做同样的事情,并添加相同的NuGet包,但是,另一个说版本。 4.1.1.2

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


然后我得到警告:


在System.Net.Http之间发现冲突

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

请注意已安装正确的版本,但是=>道具=>版本为4.1.1.2

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

推荐答案

编辑:仅当使用.NET Framework 时,才会发生这种情况。在.NET Core / Standard领域中,最新的 System.Net.Http 程序集版本似乎始终为4.1.2.0-没有可用的4.2.0.0版本。

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.

与System.Net.Http有关的问题是方式,然后此处的答案似乎意味着...

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


  1. 是的,有一个 System.Net.Http NuGet包,但是没有,它将安装同一程序集的最新版本(它包含 System.Net.Http 程序集的4.1.1.2版本,而不是4.2.0.0)。

  2. 最新的Microsoft Visual Studio(或Microsoft Visual Studio生成工具)提供了4.2.0.0版,但这并不意味着您的.csproj将始终使用它...
  3. 由于某种原因(我还无法理解),使用4.2.0.0的唯一保证方法是引用某些使用它的NuGet包,例如我们 System.Buffers (版本4.5.0为我工作)。

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

T L; DR:

添加 System.Buffers 4.5.0+ NuGet对您的项目的引用,如果您想确保使用的是 System.Net.Http 4.2.0.0程序集。

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.

参考:

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

这篇关于发现System.Net.Http之间的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆