casting objects from reflection

G

Gerald Zukrigl

I'm trying to implement a plug-in system. So I've implemented an abstract
baseclass pluginbase and a nonabstract class named pluginimplementation.
Then I've opened the assembly containing both classes with LoadFrom. When
I'm trying to cast an instance of the pluginimplementation class (which I've
retrieved by the reflection) to a pluginbase reference null is returned. Is
there a way of getting an instance, which can be used like a usual instance,
this means without calling Invoke for every methodcall? Are there any
samples?

Thank you,

Gerald Zukrigl
 
D

Daniel O'Connell

the abstract class should be defined by the application, not in the assembly
containing a plugin. This sounds like you have the pluginbase type defined
twice, one in the plugin assembly, and one in your main application.
Create an assembly that has nothing but type definitions for your plugins
and possibly plugin related helper classes(if applicable). Then reference
that assembly in both your plugin and in the main application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top