"The best overloaded compatible method has some invalid arguments"

1

I'm creating a service with a method that has an argument of type List<OrdemPais>() , and passing an object of that type to the method, but at compile time the error appears:

O melhor método sobrecarregado compatível com 'Mahikari.Business.Domain.OrdemPaisVigencia.SetOrdensPaises(System.Collections.Generic.List<Mahikari.Business.Domain.OrdemPais>)' tem alguns argumentos inválidos

This is the part of the code that the method is called:

protected void salvar_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
            return;

        SalvarEstadoOrdem();

        List<OrdemPais> OrdemPaisList = new List<OrdemPais>();


        OrdemPaisVigencia.Vigencia = dteVigencia.SelectedDate.Value;

        List<OrdemPais> ordemPaises = new List<OrdemPais>();
        foreach (KeyValuePair<int, int> ordem in ordens)
        {
            var o = new OrdemPais(ordem.Key, ordem.Value);
            ordemPaises.Add(o);
        }

        try
        {
            OrdemPaisVigencia.SetOrdensPaises(ordemPaises);

            paisService.SaveOrdemPais(OrdemPaisVigencia);
        }
        catch (Exception ex)
        {

        }

        Response.Redirect("OrdemPais.aspx", true);
    }

The method itself:

public void SetOrdensPaises(List<OrdemPais> ordemPaises)
    {
        if (ordemPaises.Any())
            this.Validation.Errors.Add(MainResource.Mensagem_ListaNaoPodeEstarVazia);

        this.OrdemPaises = ordemPaises.OrderBy(or => or.Ordem).ToList();
    }
    
asked by anonymous 28.09.2016 / 19:46

1 answer

1

Make sure the OrdemPais in

List<OrdemPais> ordemPaises = new List<OrdemPais>(); 

is exactly the same as OrdemPais in

SetOrdensPaises(List<OrdemPais> ordemPaises);

If they have the same name but are in different namespaces, they are essentially different types.

    
30.09.2016 / 21:26