.net 程序集与Newtonsoft.Json冲突

.net 程序集与Newtonsoft.Json冲突,.net,json.net,.net-assembly,.net,Json.net,.net Assembly,我需要加载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" n

我需要加载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,但它给了我一个错误:

错误80无法加载文件或程序集“Newtonsoft.Json,Version=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6eed”或其依赖项之一。定位的程序集清单定义与程序集引用不匹配。(HRESULT的例外:0x8013100)**


我今天遇到了这个问题,我从中找到了解决办法

基本上更新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>

在我的项目中安装Signal后,我遇到了同样的问题。 首先,我更新到了Newtonsoft.Json的最新版本,然后将dependentAssembly添加到我的web.config中。但是我必须在新版本中加入6.0.0.0的值,即使在我的包中声明了6.0.8版本。



我查看了JSON.net NuGet发布信息,无法找到4.5.0.0版本。此外,如果您已经拥有最新版本的库,那么您需要使用旧版本的库吗?为什么我记得NuGet之前的一切都那么简单?您从哪里获得publicKeyToken?当我尝试构建我的应用程序时,我在错误列表控制台中获得了publicKeyToken,所以我复制了它,但这是另一种获得它的方法。如果您的web.config中有其他引用,您可能会注意到它们是相等的,因此您可以从另一个程序集复制该标记。这有点混乱,但我最终使它工作起来。首先,我将我的项目从Newtonsoft 9.x更新到12.0.2。不走运。然后我回到9.x版本,重新启动VS.No go。然后我又从9.x升级到了12.0.2。不行。然后我从12.0.2升到12.0.1,然后它就开始工作了/眼卷。至少它现在起作用了。这对我8.0.3版起作用了。直到我将新版本改为8.0.0.0,它才开始工作。只是用12.0.1尝试了一下。我把它改成了12.0.0.0版本,它解决了这个问题。非常感谢。
<dependentAssembly>
  <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
  <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>