Вопрос

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?
Это было полезно?

Решение

To anyone still stuck on this. This works today for RestSharp Version 102 (Jan 2012).

  1. Manually delete the projects references to RestShart and newtonsoft JSON
  2. Go download the latest versions of RestSharp and Json.Net manually. Do not use nuget
  3. Manually add references to the dlls you just downloaded to your project

Другие советы

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.

http://nuget.org/packages/RestSharp/103.0.0-nojsondotnet

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top