简体   繁体   English

RestSharp上的FileNotFoundException

[英]FileNotFoundException on RestSharp

I'm using RestSharp in a portable dll for Xamarin and WP platform. 我在Xamarin和WP平台的便携式dll中使用RestSharp Actually I've created the method GET with this code inside of it: 实际上,我已经使用其中的以下代码创建了GET方法:

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

I set up a client with my base url, in the request variable I passed the resource to add to the base url as the documentation says. 我用基本URL设置了一个client ,在request变量中,我按照文档中的说明传递了要添加到基本URL中的资源。 And finally I execute the request saving the content inside queryResult . 最后,我执行将内容保存在queryResult的请求。 The problem is that when I execute this code, on this line: 问题是当我执行此代码时,在此行上:

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

I get: 我得到:

FileNotFoudnException was not Managed FileNotFoudnException未被管理
System.IO.FileNotFoudnException in RestSharp.Portable.HttpClient.dll RestSharp.Portable.HttpClient.dll中的System.IO.FileNotFoudnException
Cannot load the file or assembly 'System.Net.Http.Primitives, Version = 1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d503a0 无法加载文件或程序集'System.Net.Http.Primitives,版本= 1.5.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d503a0

what is wrong? 怎么了?

You either need to : 您要么需要:

  1. Install the Microsoft Http Client Libraries from NuGet. 从NuGet安装Microsoft Http客户端库
  2. If already installed, ensure you're on the latest stable version (2.2.29) 如果已经安装,请确保您使用的是最新的稳定版本(2.2.29)

Also, check this question for more details, as you may need to add a dependent assembly to your web.config as well. 另外,请检查此问题以获取更多详细信息,因为您可能还需要向Web.config中添加一个依赖程序集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM