RestSharp

时间:2016-04-14 13:34:41

标签: c# restsharp

我在Xamarin和WP平台的便携式dll中使用RestSharp。实际上我已经使用此代码创建了方法GET

var client = new RestClient("http://localhost/api/v1/");
var request = new RestRequest(requestUri, Method.GET);
var queryResult = client.Execute(request);

我使用我的基本网址设置client,在request变量中,我传递资源以添加到基本网址,正如文档所述。最后,我执行保存queryResult内的内容的请求。问题是当我执行此代码时,在这一行:

var client = new RestClient(“http://localhost/api/”);

我明白了:

  

FileNotFoudnException未受管理
  RestSharp.Portable.HttpClient.dll中的System.IO.FileNotFoudnException   无法加载文件或程序集'System.Net.Http.Primitives,Version = 1.5.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d503a0

出了什么问题?

1 个答案:

答案 0 :(得分:1)

您需要:

  1. 从NuGet安装Microsoft Http Client Libraries
  2. 如果已安装,请确保您使用最新的稳定版本(2.2.29)
  3. 另外,请检查this question以获取更多详细信息,因为可能还需要将依赖程序集添加到web.config中。