我的VS解决方案中有几个项目.每当我将"System.Net.Http"NuGet包添加到它显示为4.2.0.0版本的包时.然后我也这样做并添加相同的NuGet包,然而,另一个说版本.4.1.1.2
然后我收到警告:
发现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
Run Code Online (Sandbox Code Playgroud)
请注意安装了正确的版本,但是=> Props =>版本说4.1.1.2
根据 NuGet 的说法,我正在处理的项目安装了 System.Net.Http 版本 4.3.3。它在 Web.config 文件中有一个绑定重定向,可以将其重定向到 4.2.0.0 版,这出于某种原因起作用:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
我将其更改为指向 4.3.3.0,这是 NuGet 所说的已安装版本:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.3.0" newVersion="4.3.3.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
...但现在当我尝试调试 ASP.NET 站点时出现此错误:
Could not load file or assembly 'System.Net.Http' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
=== Pre-bind state information ===
LOG: DisplayName = System.Net.Http
(Partial)
WRN: Partial binding information …Run Code Online (Sandbox Code Playgroud) 我开始更新一些 nuget 包,并开始在构建时收到这些警告,并与 System.Net.Http 发生冲突。正如这里所建议的:
找不到 System.Net.Http 4.2.0.0 的奇怪问题
我替换了对 System.Net.Http 的所有引用以使用 nuget 版本,而不是与 Visual Studio 捆绑的版本。然后我按照随处的建议更改了所有重定向绑定(app.configs 和 web.configs),并且我在本地工作。但..
当我部署到我们的测试服务器时,我仍然收到错误
Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)
我正在使用 net 4.7.0 和 Visual Studio 2017
我搜索了我所有的配置以查找对版本 4.2.0.0 的引用,但没有找到。为什么 IIS 认为它需要这个?
我的 System.Net.Http nuget 版本是 4.3.4,但实际的 web.config 有这些行
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3"/>
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
我再次可以在本地构建和运行它,但我的服务器报告错误。
更新:我尝试在我的服务器 …