System.Net.Http version conflict causing build warning(System.Net.Http 版本冲突导致构建警告)
问题描述
nuget 包 Microsoft.Net.Http.2.0.20710.0 导致我发出构建警告,因为它使用 System.Net.Http, Version=2.0.0.0 与来自另一个包的版本 4 发生冲突.
The nuget package Microsoft.Net.Http.2.0.20710.0 is causing me a build warning because of its use of System.Net.Http, Version=2.0.0.0 which is fighting with version 4 coming from another package.
解决这个问题的最佳方法是什么?Microsoft.Net.Http.2.0.20710.0 包是否已过时,我应该在我的项目中手动引用 System.Net.Http, Version=4.0.0.0 吗?
构建输出是:
There was a conflict between "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:WorkingMyProjectpackagesMicrosoft.Net.Http.2.0.20710.0lib
et40System.Net.Http.dll].
C:WorkingMyProjectpackagesMicrosoft.Net.Http.2.0.20710.0lib
et40System.Net.Http.dll
Project file item includes which caused reference "C:WorkingMyProjectpackagesMicrosoft.Net.Http.2.0.20710.0lib
et40System.Net.Http.dll".
System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
References which depend on "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Net.Http.dll].
C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.Core.4.0.20710.0lib
et40System.Web.Http.dll
Project file item includes which caused reference "C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.Core.4.0.20710.0lib
et40System.Web.Http.dll".
System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.Client.4.0.20710.0lib
et40System.Net.Http.Formatting.dll
Project file item includes which caused reference "C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.Client.4.0.20710.0lib
et40System.Net.Http.Formatting.dll".
System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.WebHost.4.0.20710.0lib
et40System.Web.Http.WebHost.dll
Project file item includes which caused reference "C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.WebHost.4.0.20710.0lib
et40System.Web.Http.WebHost.dll".
System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
C:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets(1578,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
推荐答案
您可以尝试 此 Microsoft Connect 错误报告.
或者您可以尝试在您的 Web.config 中添加类似的内容:
Or you can try and add something like this to your Web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
这是 Connect Bug 中的解决方法:
This is the workaround in the Connect Bug:
修改.......: <Reference Include="System.Net.Http">
阅读......:<Reference Include="System.Net.Http, Version=4.0.0.0">
modify.......: <Reference Include="System.Net.Http">
to read ......: <Reference Include="System.Net.Http, Version=4.0.0.0">
这篇关于System.Net.Http 版本冲突导致构建警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:System.Net.Http 版本冲突导致构建警告
基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01