未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0

错误描述:

错误原因:

因为引用出了问题,在你的程序集里面找不到的Newtonsoft.Json,所以它就拿从系统盘里面预装的旧版的来用,结果就报版本错误了.

解决方案:

web.config  的 configuration节点下面注明

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

就要求用6.*版本的了。

你可以删除bin文件夹里面的Newtonsoft.Json,重新用nuget 引用一遍(重写nuget自动解决版本问题)。

我就只说到这里了,具体常见错误有三种情况

第一,引用不存在vs自动找到旧版的。
第二,web.config配置的版本号跟实际想要版本号不对。
第三,bin文件夹里面的根本就是旧版的。

原文地址:https://www.cnblogs.com/liuxiaoji/p/4582547.html