mardi 6 septembre 2016

Object does not match target type Exception in SetValue

//try to set this property .

 public List<USER_ROLE> list {get;set;}

var result = new List<USER_ROLE>() { new USER_ROLE()
                              { userid = 0,role_id = 1,role_cde = "00001"
                               }};
    //Get property with name of property.

object obj = Activator.CreateInstance(property.PropertyType);
var getva = property.GetValue(obj,null);// Object does not match target type


property.PropertyType.GetMethod("Add").Invoke(obj,new object[] { result });
if (obj.GetType() == property.PropertyType)
{
property.SetValue(obj, property, null);// object does not match target type.
}

Runtime execption: object does not match target type. i don't understand target type, please tell, where i am wrong?





Aucun commentaire:

Enregistrer un commentaire