I am trying to use RestSharp ( http://restsharp.org/ ) in a Windows Phone 7 project, but I have a problem. submitted using the Newtonsoft Json.NET library that RestSharp uses. When I try to execute my code like this:
_restClient.ExecuteAsync<Model.Song>(restRequest, (response) =>
{
if (response.StatusCode == HttpStatusCode.OK) { }
else { }
});
I get the following error:
Could not load type 'Newtonsoft.Json.Linq.JArray' from assembly 'Newtonsoft.Json.Compact, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30AD4FE6B2A6AEED'.
Newtonsoft.Json.Compact.dllis copied to the Bin folder of my Windows Phone 7 application, so I assume that it will be deployed to the device, but somehow it wonβt download it. Has anyone experienced / decided something similar? Thank.
As requested, a JSON example: [{"type":"Song","id":60097,"title":"A Place Where You Belong","artist":{"type":"Artist","id":17,"nameWithoutThePrefix":"Bullet For My Valentine","useThePrefix":false}}]
And classes:
[DataContract]
public class Song
{
[DataMember(Name = "id")]
public int Id { get; set; }
[DataMember(Name = "title")]
public string Title { get; set; }
[DataMember(Name = "artist")]
public Artist Artist { get; set; }
}
[DataContract]
public class Artist
{
[DataMember(Name = "id")]
public int Id { get; set; }
[DataMember(Name = "nameWithoutThePrefix")]
public string Name { get; set; }
[DataMember(Name = "useThePrefix")]
public bool UsePrefix { get; set; }
}
source
share