Forum Visual Studio

System.Net.Http in Xamarin Studio on Mac?

Title says it all... is System.Net.Http available in Xamarin Studio on Mac / OSX? If so why wouldn't it appear in my new XSC 6.0.1 installation?

Tia,

Answers

  • mattwardmattward GBMember Xamurai

    Is this for a particular project type? System.Net.Http is available in the Edit References dialog for both Android and iOS.

  • This is xamarin.forms PCL using C# / XAML, and I need system.net.http in the platform-independent code (i.e. not the .Droid or .iOS).

  • mattwardmattward GBMember Xamurai

    The System.Net.Http namespace is not available in all PCL profiles. Profile 7 is one that includes System.Net.Http. Otherwise you would need to use a NuGet package, such as Microsoft.Net.Http, if you want to use something like HttpClient in a different PCL profile.

  • ficellesficelles GBMember

    Is there a way to identify the current PCL profile? I guess I have whatever comes with the Xamarin Studio Community stable release...

  • mattwardmattward GBMember Xamurai

    Yes, you can either open the .csproj directly in a text editor, or open project options, by right clicking the project and selecting Options, or double clicking the project, then go to Build - General. The PCL profile should be displayed in that dialog and can be changed using the combo box. By default Profile 78 is generally used.

  • I'm on a Mac, I think you are referring to Visual Studio? Further reading suggests I can't do things as I'd hoped anyway as it doesn't look like there's a platform-independent http request class (I would be very happy if someone were to tell me that isn't the case)

  • mattwardmattward GBMember Xamurai

    No I am referring to Xamarin Studio.

  • I'm guessing .shproj in XS is the equivalent to .csproj in VS, but in any case it doesn't look I can do what I want in this case. Thanks for your help anyway.

  • JohnHJohnH GBMember ✭✭✭✭✭

    @JonathanQuick.7534 Actually PCLs are a Microsoft concept, not Xamarin. If you re using PCLs and want to reference classes that are not covered by PCL then you would use dependency injection, which is a standard design pattern in these situations.
    So yes you can access the classes defined in System.Net.Http by wrapping the functions you need in a class that you create that implements an interface that exposes the methods of your class. Your PCL code then only refers to your functionality by interface.

Sign In or Register to comment.