我正在尝试在 Windows Phone 7 项目中使用 RestSharp ( http://restsharp.org/ ),但我遇到了 RestSharp 使用的 Newtonsoft Json.NET 库的问题。当我试图像这样执行我的代码时:
_restClient.ExecuteAsync<Model.Song>(restRequest, (response) =>
{
if (response.StatusCode == HttpStatusCode.OK) { }
else { }
});
我收到以下错误:
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.dll
被复制到我的 Windows Phone 7 应用程序的 Bin 文件夹,所以我假设它被部署到设备上,但不知何故它不会加载它。有没有人经历过/解决过类似的事情?谢谢。
根据要求,JSON 的示例:[{"type":"Song","id":60097,"title":"A Place Where You Belong","artist":{"type":"Artist","id":17,"nameWithoutThePrefix":"Bullet For My Valentine","useThePrefix":false}}]
和课程:
[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; }
}