Forum Cross Platform with Xamarin
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Unhandled exception throws while reading the Uri link to load the data in XF Android

Dinesh4693Dinesh4693 INMember ✭✭
edited September 2017 in Cross Platform with Xamarin

My requirement is to fetch the data from a Uri link based on network connectivity and read the content in it and load the data asynchronously to ListView's ItemsSource property as like below code example.

public async void GetRequest()
if (NetworkCheck.IsInternet())
Uri geturi = new Uri(""); //replace your xml url
HttpClient client = new HttpClient();
** HttpResponseMessage responseGet = await client.GetAsync(geturi);**
string response = await responseGet.Content.ReadAsStringAsync();
XDocument doc = XDocument.Parse(response);
foreach (var item in doc.Descendants("item"))
XmlPizzaDetails ObjPizzaItem = new XmlPizzaDetails(); = item.Element("id").Value.ToString(); = item.Element("name").Value.ToString();
ObjPizzaItem.cost = item.Element("cost").Value.ToString();
ObjPizzaItem.description = item.Element("description").Value.ToString();
listviewPizza.ItemsSource = ObjPizzaList;
await DisplayAlert("XmlParsing","No network is available.","Ok");

        ProgressLoader.IsVisible = false;


The problem is, when the application is deployed in Xamarin Forms Android platform, Unhandled exception throws with no stacks trace. And runs perfectly in UWP platform.

I suspect that the issue arises due to running multiple threads in ListView control or Xamarin Forms controls including custom controls too.

So, can anyone please suggest me how do i resolve this issue. Please find the sample in the attachment.

Thanks in Advance,
Dinesh Babu Yadav

Sign In or Register to comment.