简体   繁体   English

无法加载文件或程序集'Newtonsoft.Json,版本 = 3.5.0.0

[英]Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0

I am working in c# 4.0 to read a signed request I am using the following code我在 c# 4.0 中工作以读取签名请求我正在使用以下代码

FacebookApp fap = new FacebookApp();
fap.AppId = "789485219211963"; // App ID
fap.AppSecret = "365ee9f5823698536767d608cf572a49"; 

string requested_Data = Request.Form["signed_request"];
FacebookSignedRequest fsr = fap.ParseSignedRequest(requested_Data);
IDictionary<string, string> myDic = fsr.Dictionary;

string name = myDic["name"];
string algorithm = myDic["algorithm"];

Response.Write(requested_Data + "<br>" + algorithm + "<br>" + name + "<br>");

But on the highlighted line I received following exception但是在突出显示的行上,我收到了以下异常

Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.无法加载文件或程序集“Newtonsoft.Json,版本=3.5.0.0,文化=中性,PublicKeyToken=30ad4fe6b2a6aeed”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference.找到的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (来自 HRESULT 的异常:0x80131040)

I downloaded Newtonsoft.Json.我下载了 Newtonsoft.Json。 release 1 instead of release 2 but it still not working.发布 1 而不是发布 2,但它仍然无法正常工作。 Can someone kindly help me to solve this problem, also please guide me either my way of reading signed request is correct or not if not please specify the correct way.有人可以帮我解决这个问题,也请指导我阅读签名请求的方式是否正确,如果不是,请指定正确的方式。

Thanks:谢谢:

I'm guessing you donwloaded Newtonsoft.Json v4.0, not 3.5.我猜你下载的是 Newtonsoft.Json v4.0,而不是 3.5。 Last version of 3.5 is release 8. 3.5 的最后一个版本是第 8 版。

http://json.codeplex.com/releases/view/50552 http://json.codeplex.com/releases/view/50552

I guess that you might be able to do a version forward in your web.config/app.config in order to use 4.0 instead of 3.5, because some library you are using is probably built against the 3.5 version of Newtonsoft.我想您可能可以在 web.config/app.config 中进行版本转发,以便使用 4.0 而不是 3.5,因为您使用的某些库可能是针对 Newtonsoft 的 3.5 版本构建的。

You can update it with its nuget package 'Newtonsoft.Json' using the package manager.您可以使用 package 管理器使用其 nuget package 'Newtonsoft.Json' 对其进行更新。

PM> update-package newtonsoft.json

In package manager console Visual Studio 2013在 package 管理器控制台 Visual Studio 2013

PM> Install-Package Newtonsoft.Json

Then restart Visual Studio.然后重新启动 Visual Studio。

When I ran into this problem, I found that there were 2 similar folders in yourproject/packages, one is version 6.0.5, another is 5.0.6.当我遇到这个问题时,发现yourproject/packages中有2个类似的文件夹,一个是6.0.5版本,另一个是5.0.6。

I deleted the 5.0.6 and the problem disappeared.我删除了5.0.6,问题就消失了。

I had the same problem with my Xamarin.Forms PCL WinPhone8.1 project after upgrading all NuGet packages for the solution.在为解决方案升级所有 NuGet 包后,我的 Xamarin.Forms PCL WinPhone8.1 项目遇到了同样的问题。 The problem was with Newtonsoft.Json v9.0.0 in the winPhone8.1 project.问题出在 winPhone8.1 项目中的 Newtonsoft.Json v9.0.0 上。

All other projects worked correctly.所有其他项目都正常工作。 Spent two days trawling all advice and finally resolved the problem by deleting the project, pulling a clone of the project from my git and adding back into the solution.花了两天时间搜索所有建议,最后通过删除项目解决了问题,从我的 git 中提取项目的克隆并重新添加到解决方案中。 Still failed (although the git version worked fine before the commit.)仍然失败(尽管 git 版本在提交之前运行良好。)

Deleted reference for Newtonsoft, reinstalled the old version 8.0.3, then upgraded via NuGet to V9.0.0.删除Newtonsoft的引用,重新安装旧版本8.0.3,然后通过NuGet升级到V9.0.0。

Then deleted all references to Newtonsoft from the winPhone8.1 project Bin/ARM/Debug, Bin/x86/Debug and Obj/ARM/Debug/MSIL and MDIL directories.然后从winPhone8.1项目Bin/ARM/Debug、Bin/x86/Debug和Obj/ARM/Debug/MSIL和MDIL目录中删除所有对Newtonsoft的引用。 Did a build and SUCCESS.做了一个构建和成功。

Open the Package Manager Console and execute the following:打开 Package 管理控制台并执行以下命令:

update-package newtonsoft.json 

This worked for me.这对我有用。

PM> update-package newtonsoft.json It works PM> 更新包 newtonsoft.json 它工作

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

相关问题 无法加载文件或程序集“Newtonsoft.Json”版本=11.0.0.0 - Could not load file or assembly 'Newtonsoft.Json' Version=11.0.0.0 无法加载文件或程序集“NewtonSoft.Json,版本=12.0.0.0” - Could not load file or assembly 'NewtonSoft.Json, Version=12.0.0.0' 无法加载文件或程序集Newtonsoft.json版本6.0.0.0 - Could not load file or assembly Newtonsoft.json Version 6.0.0.0 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,版本 = 10.0.0.0 - Could not load file or assembly 'Newtonsoft.Json, Version=10.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” - could not load file or assembly 'newtonsoft.json' 无法加载文件或程序集“ Newtonsoft.Json” - Could not load file or assembly 'Newtonsoft.Json' CacheManager.Serialization.Json“无法加载文件或程序集&#39;Newtonsoft.Json,Version = 8.0.0.0” - CacheManager.Serialization.Json “Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM