23

我需要加载 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>

我从包控制台安装了 Newtonsoft - 最新版本 - 但它给了我一个错误:

错误 80 无法加载文件或程序集“Newtonsoft.Json,版本=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(HRESULT 异常:0x80131040)**

4

2 回答 2

39

我今天遇到了这个问题,我在这个链接中找到了解决方案。

基本上更新 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>
于 2013-12-06T02:21:41.947 回答
8

将 SignalR 安装到我的项目后,我遇到了同样的问题。首先我更新到最新版本的 Newtonsoft.Json,然后我将dependentAssembly 添加到我的 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>
于 2015-04-25T19:14:07.483 回答