0
이 코드에서 문제를 찾을 수 없습니다. 나는 특정 종류의 속성을 찾고 그것에 대한 메서드를 호출하려고합니다.C# MethodInfo Invoke
private string GetLangTranslator(object root)
{
var properties = root.GetType().GetProperties();
foreach (var property in properties)
{
if (typeof(MultiLanguage) == property.PropertyType)
{
MethodInfo m = property.PropertyType.GetMethod("Translate");
return m.Invoke(property.PropertyType, new object[] {Value1}) as string;
}
}
return null;
}
그리고 예외는 다음과 같다 :
기능은 다음과 같다
System.Reflection.TargetException: 'Object does not match target type.'
고맙습니다! 그것은 완벽하게 작동합니다. –