I try to call a method using reflection. My object :
public class CurrentSearch
{
public string currentUniverse { get; set; }
public string currentApplication;
public string currentUsage;
...
My code :
CurrentSearch cS = SessionUtils.getCS();
cS.currentUniverse = "lol";
string methodName = "currentUniverse" ;
var test = typeof(CurrentSearch).GetMethod(methodName).Invoke(cS, null);
But i get the error "Object reference not set to an instance of an object." on the last line. I've checked cS, it's not null... What's wrong? Thx
Aucun commentaire:
Enregistrer un commentaire