我需要加载 2 个版本的程序集 Newtonsoft.Json 版本 4.0.8.0 和 4.5.0.0。我当前的配置文件:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" />
</dependentAssembly>
但它必须是:旧的 4.0.8.0 和新的 4.5.0.0
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.5.0.0" />
</dependentAssembly>
我从 Package Console 安装了 Newtonsoft - 最新版本 - 但它给了我一个错误:
Error 80 Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)**
最佳答案
我今天遇到了这个问题,我在这个 link 中找到了解决方案.
基本上更新 Newtonsoft.Json 包。并在 web.config 中注册这个程序集
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.8"/>
</dependentAssembly>
关于.net - 与 Newtonsoft.Json 的装配冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19225776/