从.NET可移植的子集HttpClient的缺失,而在Xamarin创建PCL [英] HttpClient missing from .Net portable subset while creating PCL in Xamarin
问题描述
我已经创建了Xamarin便携式类库,并希望将它用于Android应用程序。我想使用的HttpClient
此PCL中。我已经添加了微软HTTP客户端库
从的NuGet包管理器。我现在可以看到的 .NET可移植的子集
添加到我的参考。但不知何故,我仍然无法使用的HttpClient
,它不会在.NET可移植的子集显示为好。
I have created a Portable class library in Xamarin and want to use it for an android app. I want to use the HttpClient
within this PCL. I have added the Microsoft Http Client libraries
from the NuGet Package manager. I can now see the .Net portable subset
added to my references. But somehow I still cannot use the HttpClient
and it does not show in the .Net portable subset as well.
另外,我的当前配置文件
的PCL是 4.0简介158
。如果我更改配置文件到4.5,Xamarin崩溃,不打开该解决方案
Also, my Current profile
of the PCL is 4.0-Profile 158
. If I change the profile to 4.5, Xamarin crashes and does not open the solution
谁能帮助我? 谢谢
推荐答案
最简单的解决方案是面向.NET 4.5,Windows应用商店的应用程序(的Windows 8.1),Xamarin.iOS和Xamarin.Android(4.5 Profile7)。然后,你将不需要的HttpClient的NuGet包来获得这些API。
The simple solution is to target .NET 4.5, Windows Store apps (Windows 8.1), Xamarin.iOS, and Xamarin.Android (4.5-Profile7). Then you won't need the HttpClient NuGet package to get those APIs.
如果Xamarin崩溃,当您试图选择一个4.5配置文件,请确保您使用的是最新版本,然后提供有关如何瑞普它,会发生什么情况的详细信息报告的bug。
If Xamarin is crashing when you try to select a 4.5 profile, please make sure you're using the latest version and then report the bug with details about how to repro it and what happens.
此外HttpClient的的NuGet包应该允许您使用的HttpClient从PCL轮廓158.确保你使用的NuGet的最新版本。 .NET便携式子集应该总是出现在你的PCL引用,这不是涉及到的NuGet包。当您安装的HttpClient的NuGet包,你也应该看到你的推荐参考System.Net.Http和其他组件。
Also the HttpClient NuGet package should allow you to use HttpClient from PCL profile 158. Make sure you're using the latest version of NuGet. ".NET Portable Subset" should always appear in your references for a PCL, that's not related to the NuGet package. When you install the HttpClient NuGet package, you should also see references to System.Net.Http and other assemblies in your references.
这篇关于从.NET可移植的子集HttpClient的缺失,而在Xamarin创建PCL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!