asp.net - 无法在 IIS 上加载文件或程序集“System.Net.Http,版本=4.2.0.0,文化=中性”

标签 asp.net .net

这个问题在这里已经有了答案:





Strange issue with System.Net.Http 4.2.0.0 not found

(24 个回答)


1年前关闭。




我开始更新一些 nuget 包,并开始在构建时收到这些警告,这些警告与 System.Net.Http 冲突。正如这里所建议的:

Strange issue with System.Net.Http 4.2.0.0 not found

我替换了对 System.Net.Http 的所有引用以使用 nuget 版本,而不是与 Visual Studio 捆绑的版本。然后,我按照各处的建议更改了所有重定向绑定(bind)(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)

我正在使用 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> 

我再次可以在本地构建和运行它,但我的服务器报告错误。

更新:我尝试在我的服务器 web.config 上添加它
 <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.1.1.3" />
  </dependentAssembly>

这使错误消失了!但我仍然不明白为什么我需要这样做?比如为什么我的服务器认为它需要使用 4.2.0?

最佳答案

我将我的解决方案更新为 .NET Framework 4.7.2,并确保服务器已安装此版本。这解决了我的问题。之后,我可以删除绑定(bind)重定向。

关于asp.net - 无法在 IIS 上加载文件或程序集“System.Net.Http,版本=4.2.0.0,文化=中性”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55576205/

相关文章:

.net - NET Standard 与 Net Core App : when creating . NET Core 项目(使用控制台或类库)

c# - AAD : How uniquely identify users in a Web API?

asp.net - 关于 WebControl.Style 属性的一些令人困惑的事情

c# - 发送带有套接字的字符串(不是那么容易!)

.net - ASP.NET 进程中长时间运行的代码

从另一个 AppDomain 访问时,c# 脚本有错误的数据

asp.net - jQuery:WAITING执行任务直到动画完成

asp.net - 将记录器注入(inject)中间件依赖项

c# - JSON 对象在使用 JsonResult 返回时被序列化为空括号

c# - 响应式(Reactive)扩展导致 .net 进程崩溃