简体   繁体   中英

The type 'IAsyncOperationWithProgress<,>' is defined in an assembly that is not referenced.

In my Xamarin.Forms project i am trying to use HttpClient of Windows.Web.Http . I have to use that because i need to ignore some SSL errors. When i create a HttpClient object and try to call a method i get this error message:

Error CS0012 The type 'IAsyncOperationWithProgress<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.FoundationContract, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.

I ve done some research and tried everything i found but couldnt fix it. How can i fix this ? Any help would be appreciated.

In my Xamarin.Forms project i am trying to use HttpClient of Windows.Web.Http. I have to use that because i need to ignore some SSL errors. When i create a HttpClient object and try to call a method i get this error message.

You're using the Windows.Web.Http namespace is platform specific. The underlying implementation relies on the WindowsRT platform. Thus it is not cross-platform.

We recommend use System.Net.Http HttpClient module to make REST API calls in the Xamarin.Forms application. For more you could refer to Using HttpClient with Xamarin.Forms .

  • Install the package Microsoft.Net.Http from Nuget -> For making REST API calls
  • Install the package Newtonsoft.Json from Nuget -> For Serialization/Deserialization of objects.

Usage

HttpClient client = new HttpClient();
var res = await client.GetAsync("http://localhost:5000/api/todo/items");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM