2

I'm creating a Xamarin.Forms Portable application that runs fine in Android but always crashes in iOS.

I get this error:

System.NullReferenceException: Object reference not set to an instance of an object at App.ListJson+<GetPodcasts>d__2.MoveNext () [0x0004e]

It occurs at this piece of code, on the second line:

var httpClient = new HttpClient();
var json = await httpClient.GetStringAsync(REDACTEDSTRING).ConfigureAwait(false);

I've tried fiddling with the HttpClient implementation settings for the iOS project but still get the same error.

4
  • I would assume you using a non-secure URL on iOS and have not white-listed it... Commented Dec 16, 2016 at 0:06
  • What would constitute as non-secure? I am using an HTTPS url on a server with TLS 1.2 and GlobalSign verification. Commented Dec 16, 2016 at 0:14
  • I assumed wrong (http://), but since you are using TLS 1.2, are you using a native IOS HttpClient and Apple's TLS (both assigned in iOS Build options). Also whats the reasoning to using ConfigureAwaiting.. Commented Dec 16, 2016 at 0:32
  • I eventually stumbled upon a solution from another question, after sifting through at least 30 threads :P. The ConfigureAwait is from the code samples I've been learning from (I'm new to C#). Commented Dec 16, 2016 at 0:46

1 Answer 1

0

The answer found here solved my problem.

To reiterate it here:

Installing the Microsoft.Net.Http NuGet package into the base project will fix the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.