【发布时间】:2018-07-01 12:57:28
【问题描述】:
当我尝试构建我的 Asp .Net Core (1.1.2) 应用程序时,我收到以下警告:
发现不同版本的“System.Net.Http”之间存在无法解决的冲突。当日志详细程度设置为详细时,这些引用冲突会列在构建日志中。
这会变成运行时错误,因此我正在尝试修复此警告...
我在 Visual Studio 中打开了详细日志记录,我在构建输出窗口中看到了这一点:
There was a conflict between "System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll].
C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll
Project file item includes which caused reference "C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll".
System.Net.Http
References which depend on "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\System.Net.Http.dll].
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll
Project file item includes which caused reference "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll".
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
Project file item includes which caused reference "C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll".
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Persistence.MarkLogic.dll
Project file item includes which caused reference "C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Persistence.MarkLogic.dll".
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
... more dlls that reference 4.1.1.2
依赖关系
我不明白告诉我哪些“参考”依赖于System.Net.Http, Version=4.1.1.0 的部分。我正在阅读它,因为它取决于它本身。我误会了什么?
我没有通过程序集引用或 Nuget 引用直接引用 System.Net.Http。
另外,“C:\Users\mdepouw.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll”中的文件版本为4.1.1.0。
【问题讨论】:
-
这意味着您使用的两个不同的包(或您链接的解决方案中的其他项目)引用了
System.Net.Http程序集的不同版本。查看 Dependencies >NETStandard 2.0或.NET Core 2.0(或仅当您只有一个目标时的“依赖项”)并列出依赖项。如果您使用“Search Solution Explorer”字段并在其中键入“System.Net.Http”,则更容易它并查看哪些库依赖于它 -
当你混合一些东西时经常会发生这种情况,比如一些旧的 beta 或 rc 与 release 或 ASP.NET Core 1.x 与 2.x
标签: visual-studio asp.net-core msbuild nuget