I can't find the problem in this code. I'm trying to find a particular kind of property and invoke a method on it.
The function is the following:
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;
}
And the exception is the following:
System.Reflection.TargetException: 'Object does not match target type.'
Aucun commentaire:
Enregistrer un commentaire