RestSharp - Could not load file or assembly 'Newtonsoft.Json, Version=4.0.3.0
Question
I'm making a GET request to Yammer.com's REST API using RestSharp (which is awesome), and getting this error:
Could not load file or assembly 'Newtonsoft.Json, Version=4.0.3.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)
From debugging, I can see that I'm getting a good response with the Yammer.com messages I'm trying to GET, and the code is throwing the exception on the deserialization.
- Is this problem related to me writing the deserialization wrong in my code, or to an actual problem with assembly compatibility?
- How do I fix it?
Solution
To anyone still stuck on this. This works today for RestSharp Version 102 (Jan 2012).
OTHER TIPS
Probably your request to Yammer.com returns a json string (data). ..and probably their API expose a deserialization function that uses Json.NET library inside, i.e.:
YammerData dataToReturnedByApi = JsonConvert.DeserializeObject<YammerData>(jsonString);
So basically you might need to download and include JSON.NET dll into your project. The second option: you project targets .NET version lower than Json library. (i.e. 2.0 and 4.0). Try to change your .NET target to 4.0.
RestSharp's got a new package without the JSON library dependency.