Tartar
Tartar

Reputation: 5452

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.

Upvotes: 0

Views: 1021

Answers (1)

Nico Zhu
Nico Zhu

Reputation: 32775

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");

Upvotes: 1

Related Questions