gpt4 book ai didi

c# - ASP.NET MVC 需要两个不同版本的 Newtonsoft.Json.dll

转载 作者:太空狗 更新时间:2023-10-30 00:48:06 25 4
gpt4 key购买 nike

我开发了一个 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”或其依赖项之一。找到的程序集的 list 定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)

我的 href 不正确吗?? dlls文件夹与MVC项目中的Content文件夹同级

谢谢,加根

最佳答案

试试这个 assemblyBinding block ,注意细微的差别......

我已经删除了 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>

关于c# - ASP.NET MVC 需要两个不同版本的 Newtonsoft.Json.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49905735/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com