根据 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)