与Newtonsoft.Json的装配冲突

Ale*_*lex 19 .net json.net .net-assembly

我需要在我的配置文件中加载2个版本的程序集Newtonsoft.Json vesion 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>
Run Code Online (Sandbox Code Playgroud)

但我需要旧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>
Run Code Online (Sandbox Code Playgroud)

我从Package Console安装了最新版本,但它给了我错误:

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

nra*_*rez 34

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

基本上更新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>
Run Code Online (Sandbox Code Playgroud)


Ral*_*oge 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>
Run Code Online (Sandbox Code Playgroud)

  • 刚尝试使用12.0.1。我将其更改为12.0.0.0版,并解决了该问题。谢谢! (2认同)