我开发了一个 MVC 应用程序,它依赖于使用 Newtonsoft.Json.dll v6.0.0.0 的 Connectwise SDK 和使用 Newtonsoft.Json.dll v7.0.0.0 的 Dropbox SDK。
我需要确保我的项目在需要时使用适当的 dll。
经过研究,我尝试了以下方法:
- 将 2 个 dll 分别放置在子文件夹 /dlls/6.0.0.0/ 和 /dlls/7.0.0.0 下。
- 项目引用中引用了版本6.0.0.0 dll
- 添加到 web.config
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
<bindingredirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"></bindingredirect>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
<bindingredirect oldVersion="7.0.0.0-7.1.0.0" newVersion="7.0.0.0"></bindingredirect>
<codeBase version="7.0.0.0" href="dlls/7.0.0.0/Newtonsoft.Json.dll" />
</dependentAssembly>
</assemblyBinding>
无法加载文件或程序集“Newtonsoft.Json,Version=7.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)
我的href不正确吗? dlls文件夹与MVC项目中的Content文件夹处于同一级别
谢谢,
加根
尝试使用这个 assemblyBinding 块,注意细微的差异......
我已经删除了绑定重定向节点,因为您不需要它!
我已将您的 href 属性中的斜杠更改为反斜杠
当然,您需要 2 个 codeBase 节点
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
<!-- You don't need binding redirect, because you're not targeting old version to new,
---- instead you're catering to 2 different versions.
<bindingredirect oldVersion="7.0.0.0-7.1.0.0" newVersion="7.0.0.0"></bindingredirect>
-->
<codeBase version="6.0.0.0" href="bin\json6\Newtonsoft.Json.dll" />
<codeBase version="7.0.0.0" href="dlls\7.0.0.0\Newtonsoft.Json.dll" />
</dependentAssembly>
</assemblyBinding>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)