I try to add an element to a List I retrieved through reflection.
The following line
property.PropertyType.GetMethod("Add").Invoke(entity, new[] { innerValue });
is throwing an error
Object does not match target type" (Reflection.TargetException)
But the Types should match:
string listType=property.PropertyType().FullName; // System.Collections.Generic.List`1[[My.Entities.Task, My.Entities, Version=1.4.6429.20475, Culture=neutral, PublicKeyToken=null]]
string elementType=innerValue.GetType().FullName; // My.Entities.Task
entity
is an object that contains the property above
What is wrong here?
Aucun commentaire:
Enregistrer un commentaire