Search code examples
xamarin.formsdotnet-httpclient.net-standard.net-framework-version.net-standard-2.0

.net standard library with HttpCient for xamarin forms


I was trying to create a common library for using HttpClient to consume an API. I was planning to make it in .net standard so as to share it with my xamarin.forms project right now and any future ones. However the highest version of .net standard I managed to use was 1.0. HttpClient needs standard2.0. I have included the latest version of .netstandard nuget into my xamarin.forms.

I have noticed that xamarin.forms runs in net4.5. According to the documentations the max I can go with this is standard1.1. Is there any work around around these to a .net standard common project or is my only option to make a .net framework project/xamarin portable library?


Solution

  • I did manage to get HttpClient working in .net standard after manually importing the class. It needed an additional reference which is why it threw an error when I downgraded from .netcore.

    This seems to work sometimes and throws reference errors other times. These errors go when I close and re-open visual studios.