RestSharp 上的 FileNotFoundException
FileNotFoundException on 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);
我用我的基础 url 设置了一个 client
,在 request
变量中,我传递了要添加到基础 url 的资源,如文档所述。最后,我执行了将内容保存在 queryResult
中的请求。问题是当我执行这段代码时,在这一行:
var client = new RestClient("http://localhost/api/");
我得到:
FileNotFoudnException was not Managed
System.IO.FileNotFoudnException in RestSharp.Portable.HttpClient.dll
Cannot load the file or assembly 'System.Net.Http.Primitives, Version = 1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d503a0
怎么了?
您要么需要:
- 从 NuGet 安装 Microsoft Http Client Libraries。
- 如果已安装,请确保您使用的是最新的稳定版本 (2.2.29)
此外,请检查 this question 了解更多详细信息,因为您 可能 还需要向 web.config 添加依赖程序集。
我在 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);
我用我的基础 url 设置了一个 client
,在 request
变量中,我传递了要添加到基础 url 的资源,如文档所述。最后,我执行了将内容保存在 queryResult
中的请求。问题是当我执行这段代码时,在这一行:
var client = new RestClient("http://localhost/api/");
我得到:
FileNotFoudnException was not Managed
System.IO.FileNotFoudnException in RestSharp.Portable.HttpClient.dll
Cannot load the file or assembly 'System.Net.Http.Primitives, Version = 1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d503a0
怎么了?
您要么需要:
- 从 NuGet 安装 Microsoft Http Client Libraries。
- 如果已安装,请确保您使用的是最新的稳定版本 (2.2.29)
此外,请检查 this question 了解更多详细信息,因为您 可能 还需要向 web.config 添加依赖程序集。