每次运行我的项目时,我都会收到以下异常:



我尝试了几乎所有可以在网上找到的解决方案。

我的 packages.config 文件:

<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net451" />

and this in web.config file:
 <assemblyIdentity name="Newtonsoft.Json" PublicKeyToken="30ad4fe6b2a6aeed"  />
        <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.8"/>
      </dependentAssembly>

我什至使用以下命令来更新/重新安装 json.net:
update-package Newtonsoft.Json -reinstall
update-package Newtonsoft.Json

我还能尝试什么?

最佳答案

更改您的绑定(bind)重定向 newVersion 和 oldVersion 以匹配您尝试使用的 Json.net 版本:

  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" PublicKeyToken="30ad4fe6b2a6aeed"  />
    <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
  </dependentAssembly>

4.5是框架版本,不是Json.net的版本

关于c# - 如何修复 json.net (Newtonsoft.Json) 运行时文件加载异常,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35442540/

10-12 07:39
查看更多