Error "Signature (Return type) of Eventhandler..."

Asked

Viewed 481 times

1

Making a mistake:

Signature (Return type) of Eventhandler "Foodsuppy.Tela.Solicitacaocompra.Btnincluir_clicked" doesn’t match the Event type Foodsuppy.

My app buttons started giving this message after I updated the Nuget packages. I would like to know how to resolve.

Follows code:

//Botão Incluir
        private async Task BtnIncluir_Clicked(object sender, EventArgs e)
        {
            //Enviar ao banco
            Retorno retorno = await BuscarSolicitacaoCompras.BuscaInformacao("1", 0);

            await Navigation.PushAsync(new ItensCompra(Convert.ToString(retorno.ID_RET), "Incluir"));

            AtualizaDados(usuario);
        }

The code that is linked to the button is this:

//Buscar Solicitação de Compra
    class BuscarSolicitacaoCompras
    {
        private static Login1 usuarioConectado = new Login1();

        private static readonly string UrlBase = "http://sibrati.com.br/foodsupply/ie_solcompra.php?op={0}&idu={1}&ids={2}";

        public async static Task<Retorno> BuscaInformacao(string op, int ids)
        {
            usuarioConectado = Conectado.Pegar_ClienteConectado();

            string URL = string.Format(UrlBase, op, usuarioConectado.ID_USUARIO, ids);

            HttpClient http = new HttpClient();

            var response = await http.GetAsync(URL);
            var content = await response.Content.ReadAsStringAsync();
            var retorno = JsonConvert.DeserializeObject<Retorno>(content);

            return retorno;
        }
    }

1 answer

1


Events of any kind do not return values, are "void". It is complaining that the BtnIncluir_Clicked is not compatible with EventHandler, which has the following signature:

public void Método(object sender, EventArgs e);

This occurs due to the existence of the return Task. Try to put void and see if the compiler accepts.

With that response from a partner I simply switched the Task for void:

private async void BtnIncluir_Clicked(object sender, EventArgs e)
{
   ...
}

Browser other questions tagged

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