how do i invoke methods of a class of mine thru reflection? how do i invoke static and non-static methods? tks
Printable View
how do i invoke methods of a class of mine thru reflection? how do i invoke static and non-static methods? tks
Remember this
http://www.vbforums.com/showthread.p...=plugin+cander
look at the InvokeMember part.
hmm yea i suck sorry
:p
hmm that example sucks a bit because i dont have the interface and that thing doesnt even instantiate the class..or does it? an code that i can put in vs.net and see it work or something like that would be a lot better :\
edit: hmm actually it creates an instance..let me check it again..grr
just take out the interface stuff and use the object's name isntead of IPlugin for casting.
btw how does it know if the interface PLUGIN that the caller has is the same as the plugin has?
hmm i am not achieving what i want..i keep getting an "instance Additional information: Specified cast is not valid.
" or whatever:
plugin interfaceCode:private void button1_Click(object sender, System.EventArgs e) {
Assembly asm = Assembly.LoadFrom("teste.dll");
object classTest = asm.CreateInstance("BRANCO_Class");
object[] _params = {};
IPlugin plugin;
System.Type[] types = asm.GetTypes();
foreach (System.Type type in types) {
plugin = (IPlugin)Activator.CreateInstance(type);
}
}
edit: i think i finally did it...Code:public interface IPlugin {
void attack();
}
edit2: FINALLY DID IT :D
hmm...now i have a different case...i have a plugin which has a form...that form has a control(a Panel)...i already created an instance of the form...now how do i retrieve the panel off it? which kind of thing is the panel? a field? i tried listing all fields using GetFields() but none field appear...
any suggestions?