1
I’m creating a service with a method that has an argument like List<OrdemPais>()
, and passing an object of this type to the method, but when compiling it appears the error:
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();
}
The error is in the build or execution?
– Jéf Bueno
Compilation, and the strange thing is that it doesn’t signal with the red underscore (which usually stays in the visual studio when it’s wrong).
– William
I can not identify any problem seeing only this. It may be missing something. But this code has several strange things. I don’t know if the problem may be being caused by something else. If you can make a [mcve] it may be easier to help.
– Maniero
I’m going to put the whole method of that code snippet, which has weird @bigown ?
– William
It’s strange because both the call and the signature apparently has the same type. Certifies that the
OrdemPais
inList<OrdemPais> ordemPaises = new List<OrdemPais>();
is exactly the same inSetOrdensPaises(List<OrdemPais> ordemPaises)
. I mean, if they are not being referenced from separate Dlls despite having the same name.– Eric Wu
@Ericwu was exactly that, the class (which is in another DLL) had the same name as a page, so it gave the error. If you want you can answer the question so I can mark it as an answer!
– William