I'm trying to use reflection to get the data from a variable sent to the method as object, and I'm having the following error: "Object reference not set to an instance of an object."
The code:
public object SendNetworkData(object input, Classes.Macro Command)
{
if (input is Classes.Authentication)
{
string Username = input.GetType().GetProperty("UserName").GetValue(input, null).ToString();
string Password = input.GetType().GetProperty("Password").GetValue(input, null).ToString();
Classes.Authentication InputAccount = new Classes.Authentication(Username, Password);
return InputAccount;
}
}
The problem arise at Line 5, and, as I am trying to debug, if I type input into watch, I get this: Debug watch
input contains those two members, but for some reason, I get an "Object reference not set to an instance of an object." exception. What can be the reason of this error?
Aucun commentaire:
Enregistrer un commentaire