Xamarin.Forms Android Error - new Httpclient()

Asked

Viewed 238 times

0

This error (image) appears whenever you arrive on this line:

using (var client = new HttpClient())

inserir a descrição da imagem aqui

This is the complete code.

using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace LivrosApp.ApiLivros
{
    public static class Api
    {
        public static async Task<IList<Model.Livro>> GetAsync()
        {
            using (var client = new HttpClient())
            {
                var json = await client.GetStringAsync("http://mvalivros.azurewebsites.net/api/livros");
                var livros = JsonConvert.DeserializeObject<List<Model.Livro>>(json);
                return livros;
            }
        }
    }
}

I have remade the solution, I already gave Clean in the solution and in the projects, I built, I rebuilt, activated all the exceptions... Nothing works...

I marked all functions below also.

inserir a descrição da imagem aqui

  • Dude, go to Debug > Windows > Exceptions and tell me if the option Common Language Runtime Exceptions is marked with a tick ( ), a square or is not marked

  • Hi. All this... I put in question an image.

  • Add a Try/Cath to check the generated Exception. Something else are you testing this on an Android VM? Check if there is internet in this VM?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.