Gag*_*ags 4 c# model-view-controller dll json.net assembly-binding-redirect
我已经开发了一个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>
Run Code Online (Sandbox Code Playgroud)
无法加载文件或程序集“ Newtonsoft.Json,版本= 7.0.0.0,区域性=中性,PublicKeyToken = 30ad4fe6b2a6aeed”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(来自HRESULT的异常:0x80131040)
我的href错误吗?dlls文件夹与MVC项目中的Content文件夹处于同一级别
谢谢,甘根
尝试使用该assemblyBinding块,请注意细微差别...
我删除了bindingredirect节点,因为您不需要它!
我在您的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>
Run Code Online (Sandbox Code Playgroud)
我也遇到了同样的问题。我使用此链接中提到的代码库方法解决了问题。 https://devnet.kentico.com/articles/referencing-multiple-versions-of-the-same-assemble-in-a-single-application
| 归档时间: |
|
| 查看次数: |
2155 次 |
| 最近记录: |