5

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

2
  • What platforms do you want to target? If you need iOS and Android only and no WP8, select .NET45, iOS, Android and Windows 8 Store Apps. That will give you HttpClient without having to add anything from Nuget.
    – Krumelur
    Feb 18, 2014 at 9:22
  • @Krumelur I tried doing that but Xamarin crashes as soon as i change it to 4.5 n the solution never opens after tht Feb 18, 2014 at 9:26

1 Answer 1

8

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.