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.
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
Can anyone help me with this? Thanks
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With