|
-
Feb 6th, 2003, 01:29 PM
#1
Thread Starter
yay gay
Invoke methods thru reflection
how do i invoke methods of a class of mine thru reflection? how do i invoke static and non-static methods? tks
\m/  \m/
-
Feb 6th, 2003, 01:33 PM
#2
-
Feb 6th, 2003, 01:35 PM
#3
Thread Starter
yay gay
\m/  \m/
-
Feb 6th, 2003, 01:36 PM
#4
-
Feb 6th, 2003, 01:58 PM
#5
Thread Starter
yay gay
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
\m/  \m/
-
Feb 6th, 2003, 02:01 PM
#6
just take out the interface stuff and use the object's name isntead of IPlugin for casting.
-
Feb 6th, 2003, 02:21 PM
#7
Thread Starter
yay gay
btw how does it know if the interface PLUGIN that the caller has is the same as the plugin has?
\m/  \m/
-
Feb 7th, 2003, 01:51 PM
#8
Thread Starter
yay gay
hmm i am not achieving what i want..i keep getting an "instance Additional information: Specified cast is not valid.
" or whatever:
Code:
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);
}
}
plugin interface
Code:
public interface IPlugin {
void attack();
}
edit: i think i finally did it...
edit2: FINALLY DID IT
Last edited by PT Exorcist; Feb 7th, 2003 at 02:33 PM.
\m/  \m/
-
Mar 16th, 2003, 03:35 PM
#9
Thread Starter
yay gay
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?
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|