I need to create an instance of object dynamically and execute one method of this instance dynamically. I am trying this code but GetMethod return null.
var className = "SomeClass";
Type[] paramTypes = { typeof(Telegram.Bot.Types.User), typeof(string[]) };
var cmd = Activator.CreateInstance(null, "mynamespace." + className);
var method = cmd.GetType().GetMethod("Execute", BindingFlags.Public|BindingFlags.Instance, null, paramTypes, null);
res = method.Invoke(cmd, new object[] { e.Message.From, args }).ToString();
how can i solve this problem?
Aucun commentaire:
Enregistrer un commentaire