简体   繁体   English

System.IO.FileNotFoundException: '无法加载文件或程序集 'Newtonsoft.Json,版本 = 12.0.0.0,

[英]System.IO.FileNotFoundException: 'Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0,

This is the error that I get:这是我得到的错误:

System.IO.FileNotFoundException: 'Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. System.IO.FileNotFoundException: '无法加载文件或程序集'Newtonsoft.Json,版本=12.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed'。 The system cannot find the file specified.'该系统找不到指定的文件。'

This is what I have in cs project:这是我在 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>

The path seems to be correct.路径似乎是正确的。

I tried to find different solutions such as reinstalling the package to earlier version and modifying the app.config to this:我试图找到不同的解决方案,例如将软件包重新安装到早期版本并将 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>

Nothing has worked.没有任何效果。

In my case, I have installed the V 12.0.0.3 by the Nuget package and I got the same error.就我而言,我已经通过 Nuget 包安装了 V 12.0.0.3 ,但遇到了同样的错误。 According to my own experience .根据我自己的经验。 some of NewtonSoft versions are getting mad with some version of the Visual studio.某些NewtonSoft版本对某些版本的 Visual Studio感到厌烦

if you just need simple deserialize and serialize functionality, your problem will be solved if you reinstall the Newtonsoft current package from your solution and install the version 6.0.3如果您只需要简单的序列化序列化功能,如果您从您的解决方案中重新安装 Newtonsoft 当前包并安装6.0.3版本,您的问题将得到解决

This version is so compatible with visual studio different versions.此版本与 Visual Studio 的不同版本非常兼容。

Even though I had installed the Newtonsoft via "Manage NuGet Packages for Solution" I was still receiving this error.即使我已经通过“管理 NuGet 解决方案包”安装了 Newtonsoft,我仍然收到此错误。 My fix was simple – I had to also add the "Newtonsoft.Json.dll" as a reference.我的修复很简单——我还必须添加“Newtonsoft.Json.dll”作为参考。

1.  Right-click "References" > Add > Reference > Browse > C:\Users\<username>\.nuget\packages\newtonsoft.json\12.0.3\lib\portable-net45+win8+wp8+wpa81\Newtonsoft.Json.dll > Click the "Add" button > Click "OK"
2.  I did a Build/Clean Solution (that step may not have been necessary)
3.  Build/Build Solution

Reran and the exception was gone. Reran,异常消失了。

This worked for me :这对我有用:

My issue : Recently updated newtonsoft to 13.0.0.0 and now VS is complaining about missing 9.0.0.0我的问题:最近将 newtonsoft 更新到 13.0.0.0,现在 VS 抱怨缺少 9.0.0.0

  1. Check the version of your Newtonsoft.JSON in References在参考资料中检查 Newtonsoft.JSON 的版本在此处输入图片说明

  2. Open Web.Config and change the bindingRedirect to the version in your reference打开 Web.Config 并将 bindingRedirect 更改为您参考中的版本在此处输入图片说明

In your error it is stated that library version "12.0.0.0" was not found.在您的错误中指出未找到库版本“12.0.0.0”。 In your config reference the version listed is "12.0.3"在您的配置参考中,列出的版本是“12.0.3”

The version mismatch could be the cause here.版本不匹配可能是这里的原因。

When i encounter this issue it is usually after checking out code from source control and for some reason the references are missing.当我遇到这个问题时,通常是在从源代码管理中检出代码之后,并且由于某种原因缺少引用。 In this case it helped me to uninstall the nugets, check in, reinstall them and build (and check in again).在这种情况下,它帮助我卸载了 nuget,签入,重新安装并构建(并再次签入)。 Maybe this will work for you.也许这对你有用。

I had this exact same issue, i was working on a Web API and a self written DLL i wanted to debug.我有这个完全相同的问题,我正在研究一个 Web API 和一个我想调试的自写 DLL。

Working on my DLL in the other project gave me this error.在另一个项目中处理我的 DLL 给了我这个错误。

But i followed these steps to finally resolve my issue:但我按照以下步骤最终解决了我的问题:

  1. Reinstall Newtonsoft.Json重新安装 Newtonsoft.Json
  2. Restart Visual Studio重新启动 Visual Studio
  3. Clean solution ( i believe this is the real solution )干净的解决方案(我相信这是真正的解决方案
  4. Build/Rebuild solution构建/重建解决方案

I suspect that when your project runs it isn't reading the .config that you expect because it is running from a different process.我怀疑当您的项目运行时,它没有读取您期望的 .config,因为它是从不同的进程运行的。 Try renaming your .config to match the calling process.尝试重命名您的 .config 以匹配调用过程。

It might help to give more details about the type of VS project that you have.提供有关您拥有的 VS 项目类型的更多详细信息可能会有所帮助。

This feels like one of those deja-vu issues for me - this particular time this exception was being thrown when my C# EXE file trying to call a web service.这对我来说就像是似曾相识的问题之一 - 在这个特殊的时间,当我的 C# EXE 文件试图调用 Web 服务时抛出了这个异常。 After trying to uninstall/reinstall/clean/rebuild/restart VStudio a dozen or so times I finally found a solution which was to just copy the files "Newtonsoft.Json.dll" and "Newtonsoft.Json.xml" to the output directory (alongside the EXE) - after doing this the error FINALLY went away.在尝试卸载/重新安装/清理/重建/重新启动 VStudio 十几次后,我终于找到了一个解决方案,只需将文件“Newtonsoft.Json.dll”和“Newtonsoft.Json.xml”复制到输出目录(与 EXE 一起) - 执行此操作后,错误最终消失了。 FWIW I realize this is very likely a hacky/ugly solution and not really solving the core issue - I'm just happy I can move on now. FWIW 我意识到这很可能是一个笨拙/丑陋的解决方案,并没有真正解决核心问题 - 我很高兴我现在可以继续前进。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集 &#39;Newtonsoft.Json,版本 = 12.0.0.0? - Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0? 无法加载文件或程序集“NewtonSoft.Json,版本=12.0.0.0” - Could not load file or assembly 'NewtonSoft.Json, Version=12.0.0.0' System.IO.FileNotFoundException:无法加载文件或程序集“Microsoft.ReportViewer.Common,版本=12.0.0.0,文化=中性,PublicKeyToken= - System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken= 无法使用 Google.Apis 加载文件或程序集 'Newtonsoft.Json,版本 = 12.0.0.0 问题。* - Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0 issue using Google.Apis.* 在容器 dotnet 核心容器中运行时,无法加载文件或程序集“Newtonsoft.Json,版本 = 12.0.0.0” - Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0 when running in container dotnet core container System.IO.FileNotFoundException,Newtonsoft.Json .Net - System.IO.FileNotFoundException, Newtonsoft.Json .Net .NET 6 System.IO.FileNotFoundException:无法加载文件或程序集 System.Linq,版本 = 6.0.0.0 - .NET 6 System.IO.FileNotFoundException: Could not load file or assembly System.Linq, Version=6.0.0.0 System.IO.FileNotFoundException:无法加载文件或程序集 - System.IO.FileNotFoundException: Could not load file or assembly System.IO.FileNotFoundException: '无法加载文件或程序集 - System.IO.FileNotFoundException: 'Could not load file or assembly 无法加载文件或程序集System.IO.FileNotFoundException - Could not load file or assembly System.IO.FileNotFoundException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM