无法在IIS上加载文件或程序集'System.Net.Http,Version = 4.2.0.0,Culture = neutral [英] Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral on IIS

查看:215
本文介绍了无法在IIS上加载文件或程序集'System.Net.Http,Version = 4.2.0.0,Culture = neutral的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始更新一些nuget软件包,并开始在构建时出现这些警告,但System.Net.Http发生冲突.如这里的建议:

I started updating some nuget packages and started getting these warnings on build with a conflict for System.Net.Http. As suggested here:

奇怪找不到System.Net.Http 4.2.0.0的问题

我替换了对System.Net.Http的所有引用,以使用nuget版本,而不是与Visual Studio捆绑在一起的版本.然后,我按照各地的建议更改了所有重定向绑定(app.configs和web.configs),并使事情在本地运行.但是..

I replaced all references to System.Net.Http to use the nuget version, instead of the one bundled with Visual Studio. I then changed all redirect bindings (app.configs and web.configs) as suggested everywhere and I got things working locally. But..

当我部署到测试服务器时,仍然出现错误

When I deploy to our test server I still get the error

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

I´m using net 4.7.0 and Visual Studio 2017

我在所有配置中搜索了对版本4.2.0.0的引用,但未找到任何结果.IIS为什么认为它需要这个?

I searched all my configs for a ref to Version 4.2.0.0 but no hits. Why does the IIS think it needs this one?

我的System.Net.Http的nuget版本是4.3.4,但实际的web.config包含以下几行

My nuget version of the System.Net.Http is 4.3.4 but the actual web.config has these lines

<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> 

同样,我可以在本地构建和运行它,但是我的服务器报告错误.

Again I can build and run it locally but my server reports the error.

更新:我尝试将其添加到我的服务器上web.config

UPDATE: I tried adding this on my servers 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?

That makes the error go away! But I still dont get why i need to do this? Like why do my server think it needs to use 4.2.0?

推荐答案

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

I updated my solution to .NET Framework 4.7.2 and also made sure the server had this version installed. That solved my problems. After that i can remove the binding redirect.

这篇关于无法在IIS上加载文件或程序集'System.Net.Http,Version = 4.2.0.0,Culture = neutral的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆