.net 与 Newtonsoft.Json 的装配冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19225776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Assembly Conflict with Newtonsoft.Json
提问by Alex
I need to load 2 versions of assembly Newtonsoft.Json version 4.0.8.0 and 4.5.0.0. My current config file :
我需要加载 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>
but it needs to be: old 4.0.8.0 and new 4.5.0.0
但它必须是:旧的 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>
I installed Newtonsoft from Package Console - the latest version - but it gives me an error:
我从 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)**
错误 80 无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed”或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)**
回答by nramirez
I got this problem today, I found the solution in this link.
我今天遇到了这个问题,我在这个链接中找到了解决方案。
Basically update the Newtonsoft.Json package. And register this assembly in the web.config
基本上更新 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>
回答by Ralf D'hooge
I had the same problem after installing SignalR to my project. First I updated to the latest version of Newtonsoft.Json, and then I add the dependentAssembly to my web.config. But I had to put the value of 6.0.0.0 in the new Version, even if in my packages I have version 6.0.8 declared.
将 SignalR 安装到我的项目后,我遇到了同样的问题。首先我更新到最新版本的 Newtonsoft.Json,然后我将依赖程序集添加到我的 web.config。但是我不得不将 6.0.0.0 的值放在新版本中,即使在我的包中我声明了 6.0.8 版本。
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>

