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

Found conflicts between System.Net.Http(发现 System.Net.Http 之间存在冲突)
本文介绍了发现 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

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:...Servicepackages'
Added package 'System.Net.Http.4.3.3' to folder 'C:...Servicepackages'
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 包,但是不,它不会安装同一程序集的最新版本(它包含版本 4.1.System.Net.Http 程序集的 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).

TL;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/25773
  • (https://github.com/dotnet/corefx/issues/22781-断开的链接)
  • https://github.com/dotnet/corefx/issues/17522
  • https://github.com/dotnet/corefx/issues/25773
  • (https://github.com/dotnet/corefx/issues/22781 -broken link)

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)