【问题标题】:FileNotFoundException on RestSharpRestSharp 上的 FileNotFoundException
【发布时间】:2016-08-06 02:32:56
【问题描述】:

我在 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 未被管理
RestSharp.Portable.HttpClient.dll 中的 System.IO.FileNotFoudnException
无法加载文件或程序集 'System.Net.Http.Primitives,版本 = 1.5.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d503a0

怎么了?

【问题讨论】:

    标签: c# restsharp


    【解决方案1】:

    你要么需要:

    1. 从 NuGet 安装 Microsoft Http Client Libraries
    2. 如果已安装,请确保您使用的是最新的稳定版本 (2.2.29)

    此外,请查看this question 了解更多详细信息,因为您可能还需要将依赖程序集添加到您的 web.config 中。

    【讨论】:

    • 感谢您的回答,我刚刚删除了库并重新安装以解决此问题。
    猜你喜欢
    • 2013-01-11
    • 2011-10-25
    • 1970-01-01
    • 2011-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-17
    相关资源
    最近更新 更多