PC Review


Reply
Thread Tools Rate Thread

casting objects from reflection

 
 
Gerald Zukrigl
Guest
Posts: n/a
 
      24th Aug 2003
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




 
Reply With Quote
 
 
 
 
Daniel O'Connell
Guest
Posts: n/a
 
      24th Aug 2003
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.
"Gerald Zukrigl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Casting when using reflection =?Utf-8?B?T2xkbWFu?= Microsoft Dot NET Framework 2 31st Aug 2007 12:06 PM
C# Casting following Reflection Pete Microsoft Dot NET Framework 4 17th Oct 2005 10:43 AM
reflection / casting cv Microsoft C# .NET 2 5th Nov 2004 07:50 AM
Casting an Enumeration (Reflection) Alicia Microsoft C# .NET 4 18th Oct 2004 08:43 PM
Reflection Help: Copying data between objects using reflection Joe Bloggs Microsoft C# .NET 2 25th Mar 2004 09:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:36 AM.