Shahid Rasul
Shahid Rasul

Reputation: 245

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

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. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I downloaded Newtonsoft.Json. release 1 instead of release 2 but it still not working. 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:

Upvotes: 17

Views: 64794

Answers (7)

Mark
Mark

Reputation: 1

Open the Package Manager Console and execute the following:

update-package newtonsoft.json 

This worked for me.

Upvotes: 0

cryty
cryty

Reputation: 1

PM> update-package newtonsoft.json It works

Upvotes: -1

user3763081
user3763081

Reputation: 43

I had the same problem with my Xamarin.Forms PCL WinPhone8.1 project after upgrading all NuGet packages for the solution. The problem was with Newtonsoft.Json v9.0.0 in the winPhone8.1 project.

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. Still failed (although the git version worked fine before the commit.)

Deleted reference for Newtonsoft, reinstalled the old version 8.0.3, then upgraded via NuGet to 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. Did a build and SUCCESS.

Upvotes: 1

cheny
cheny

Reputation: 2725

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.

I deleted the 5.0.6 and the problem disappeared.

Upvotes: 2

Azadeh Khojandi
Azadeh Khojandi

Reputation: 4074

You can update it with its nuget package 'Newtonsoft.Json' using the package manager.

PM> update-package newtonsoft.json

Upvotes: 9

Michael
Michael

Reputation: 339

In package manager console Visual Studio 2013

PM> Install-Package Newtonsoft.Json

Then restart Visual Studio.

Upvotes: 3

jishi
jishi

Reputation: 24614

I'm guessing you donwloaded Newtonsoft.Json v4.0, not 3.5. Last version of 3.5 is release 8.

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.

Upvotes: 18

Related Questions