admin管理员组

文章数量:1644425

文章目录

  • 问题
  • 解决


问题

系统开发完进行生产环境测试时出现错误:

英文版:
Could not load file or assembly ‘System.Net.Http, Version=4.1.1.2, 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)

中文版:
未能加载文件或程序集“System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

解决

Microsoft Visual Studio 中双击打开System.Net.Http.dll,再双击打开1 [非特定语言]


在启动项目的web.configapp.config中添加以下配置

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />
</dependentAssembly>

完整结构:

<configuration>  
   <runtime>  
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
        <dependentAssembly>
            <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />
        </dependentAssembly>
      </assemblyBinding>  
   </runtime>  
</configuration> 

这里使用了 版本重定向


拓展阅读:

  • 解决办法:Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging
  • How the Runtime Locates Assemblies | Microsoft Docs
  • c# - Could not load file or assembly 'System.Net.Http - Stack Overflow

本文标签: SystemNETassemblyloadfile