简体   繁体   English

无法加载文件或程序集'Newtonsoft.Json,Version = 10.0.0.0' - 但bin文件夹中存在二进制文件

[英]Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0' - However binary exists in bin folder

I am trying to do something pretty simple here, and I've been stuck on it for several hours. 我想在这里做一些非常简单的事情,而且我已经坚持了几个小时。 I feel like I've exhausted almost every option. 我觉得我已经筋疲力尽几乎所有的选择。

All I am trying to do is: JsonConvert.SerializeObject(model) 我要做的就是: JsonConvert.SerializeObject(model)

However, the resulting error is: 但是,产生的错误是:

Exception thrown: 'System.IO.FileLoadException' in mscorlib.dll 抛出异常:mscorlib.dll中的“System.IO.FileLoadException”

Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=982hs0cm1kd' or one of its dependencies. 附加信息:无法加载文件或程序集'Newtonsoft.Json,Version = 10.0.0.0,Culture = neutral,PublicKeyToken = 982hs0cm1kd'或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference. 定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (HRESULT异常:0x80131040)

However, in my project, I am referencing version 10.0.0.0. 但是,在我的项目中,我引用的是10.0.0.0版。 More Specifically, 10.0.2.0. 更具体地说,10.0.2.0。 When I checked my bin folder for the project, I can verify that the 10.0.2.0 dll is there. 当我检查项目的bin文件夹时,我可以验证10.0.2.0 dll是否存在。 In packages.config, I have <package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" /> 在packages.config中,我有<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />

Things I have tried: 我尝试过的事情:

  1. Manually deleteing the bin/obj folders from the project and rebuilding 从项目中手动删除bin / obj文件夹并重建
  2. Manually Modifying the Web.Config file to ensure the right version in the binding redirect. 手动修改Web.Config文件以确保绑定重定向中的正确版本。
  3. Updating the Reference Property 'Specific Version' to False 将引用属性的“特定版本”更新为False
  4. Manually delete all of the files in C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root 手动删除C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root所有文件C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root

I am really stuck here, and I can see this is a common problem as I found a lot of different approaches to fix it, however none have worked so far. 我真的被困在这里,我可以看到这是一个常见问题,因为我找到了许多不同的方法来修复它,但到目前为止还没有任何方法。

Any ideas? 有任何想法吗?

In package manager console execute: Update-Package –reinstall Newtonsoft.Json. 在包管理器控制台中执行:Update-Package -reinstall Newtonsoft.Json。

source 资源

Just had a similar issue. 刚遇到类似的问题。 My website and a referenced project (I assume same for assembly) both required Newtonsoft.Json but they had slightly different versions. 我的网站和引用的项目(我假设组装相同)都需要Newtonsoft.Json,但它们的版本略有不同。

Seems the website was winning out, so the site had that version installed and the referenced assembly failed to load "it's" version. 似乎该网站已经获胜,因此该网站安装了该版本,并且引用的程序集未能加载“它的”版本。

Made sure all the projects had the same version (Manage NuGet Packages for Solution) and worked. 确保所有项目都具有相同的版本(管理解决方案的NuGet包)并且工作正常。

暂无
暂无

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

相关问题 无法加载文件或程序集 &#39;Newtonsoft.Json,版本 = 10.0.0.0 - Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0 无法在Azure函数中加载文件或程序集&#39;Newtonsoft.Json,Version = 10.0.0.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed&#39; - Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' in Azure Functions Newtonsoft.Json版本8.0.2无法加载文件或程序集错误 - Newtonsoft.Json version 8.0.2 Could not load file or assembly Error 无法加载文件或程序集 &#39;Newtonsoft.Json,版本 = 12.0.0.0? - Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0? 无法加载文件或程序集 &#39;Newtonsoft.Json,版本 = 7.0.0.0 - Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0 无法加载文件或程序集Newtonsoft.json版本6.0.0.0 - Could not load file or assembly Newtonsoft.json Version 6.0.0.0 无法加载文件或程序集“Newtonsoft.Json”版本=11.0.0.0 - Could not load file or assembly 'Newtonsoft.Json' Version=11.0.0.0 无法加载文件或程序集'Newtonsoft.Json,版本 = 3.5.0.0 - Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0 无法加载文件或程序集“NewtonSoft.Json,版本=12.0.0.0” - Could not load file or assembly 'NewtonSoft.Json, Version=12.0.0.0' 无法加载文件或程序集“ Newtonsoft.Json” - Could not load file or assembly 'Newtonsoft.Json'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM