[英]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: 我尝试过的事情:
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? 有任何想法吗?
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.