伙计们我有以下循环,如果是列表我要再次循环,直到在这里我没事,但在这个另一个循环内我有一个问题,因为我要循环不是“propretyinfo”,我已经到循环在这个PropretyInfo的对象,并得到这个值,我已经尝试了硬解析此:解析proprety信息C#
(List<ItemDeMescla>)objeto.GetValue(objeto, null)
但它抛出excepetion,任何想法如何解析它和工作?
foreach (PropertyInfo objeto in processo.GetType().GetProperties())
{
corpoEmail += CriarLinhaEmail(objeto.Name, Convert.ToString(objeto.GetValue(processo, null)), false);
if (objeto.PropertyType.IsGenericType && (objeto.PropertyType.GetGenericTypeDefinition() == typeof(System.Collections.Generic.List<>)))
{
List<ItemDeMescla> itensMescla = (List<ItemDeMescla>)objeto.GetValue(objeto, null);
foreach (ItemDeMescla item in itensMescla)
{
tabelasAux.Add(CriarTabelaInternaEmail<ItemDeMescla>(item, objeto.Name));
}
}
}
错误堆栈:
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
at SACG.Services.Integracao.Integracao.Utils.MontarCorpoEmail[T](T processo, String mensagem) in c:\Projetos\Cotrijal\Branch\1.8.0.0\Cotrijal\Servicos\SACG.Services.Integracao\Integracao\Utils.cs:line 176
at SACG.Services.Integracao.Integracao.Utils.EnviarEmail[T](T processo, Int32 codigoDaUnidade, String mensagem, String assunto) in c:\Projetos\Cotrijal\Branch\1.8.0.0\Cotrijal\Servicos\SACG.Services.Integracao\Integracao\Utils.cs:line 114
at SACG.Services.Integracao.Integracao.IntegracaoDaExpedicao.SalvarExpedicao(ExpedicaoGraos expedicaoDto, Usuario usuarioLogado) in c:\Projetos\Cotrijal\Branch\1.8.0.0\Cotrijal\Servicos\SACG.Services.Integracao\Integracao\IntegracaoDaExpedicao.cs:line 111
at SACG.Services.Integracao.ExpedicaoDeGraos.RegistrarExpedicao(ExpedicaoGraos expedicao) in c:\Projetos\Cotrijal\Branch\1.8.0.0\Cotrijal\Servicos\SACG.Services.Integracao\ExpedicaoDeGraos.asmx.cs:line 104
它扔什么样的例外? – slawekwin
你试图完成什么? – WiiMaxx
错误信息会比堆栈跟踪本身更有帮助 – slawekwin