首页 > 解决方案 > System.IO.FileNotFoundException:'无法加载文件或程序集'Newtonsoft.Json,版本 = 12.0.0.0,

问题描述

这是我得到的错误:

System.IO.FileNotFoundException:'无法加载文件或程序集'Newtonsoft.Json,版本 = 12.0.0.0,文化 = 中性,PublicKeyToken = 30ad4fe6b2a6aeed'。该系统找不到指定的文件。'

这就是我在cs项目中的内容:

<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>

路径似乎是正确的。

我试图找到不同的解决方案,例如将软件包重新安装到早期版本并将 app.config 修改为此:

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

没有任何效果。

标签: c#

解决方案


就我而言,我已经通过 Nuget 包安装了 V 12.0.0.3,我得到了同样的错误。根据我自己的经验。一些 NewtonSoft版本对 Visual Studio 的某些版本感到愤怒。

如果您只需要简单的反序列化和序列化功能,如果您从解决方案重新安装 Newtonsoft 当前软件包并安装版本6.0.3 ,您的问题将得到解决

此版本与 Visual Studio 不同版本非常兼容。


推荐阅读