Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / January 2006

Tip: Looking for answers? Try searching our database.

CreateInstance() instance can't get back to base type at design ti

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Creel - 14 Jan 2006 23:07 GMT
I have derived a small example of the problem mentioned above.  It is setup
like this:

Assembly 'PluginHelper' has a class named 'Helper'.
Assembly 'PluginFramework' has a class named 'PluginBase' and a class named
'TextPlugin' that inherits 'PluginBase'.
Assembly 'PluginImpl' has a class named 'TextPlugin' that inherits
'PluginFramework.TextPlugin'

'PluginHelper.Helper' uses reflection to load the 'PluginFramework' assembly
and call a static method on the 'TextPlugin' class.
The static method on the 'TextPlugin' class calls a static method on
'PluginFramework.PluginBase' (its parent).
The static method on the 'PluginBase' class uses reflection to load the
'PluginImpl' assembly and create an instance of the 'PluginImpl.TextPlugin'
class.  It then casts the instance to 'PluginBase' and returns it to the
caller ('PluginFramework.TextPlugin').

The expected behavior is for the plugin base class to get an instance of the
text plugin implmentation class and cast that back to the plugin base class -
it is a grandparent, after all.

This works fine at run time!

To test at design time (where I *really* need it in my real project), I
created a simple windows app project and added a simple custom button that
inherits from Button.  In the custom button constructor it sets its own text
to a value returned from the static method on 'PluginHelper.Helper'.  This
works fine at run time, but trying to view a form containing this button in
the designer doesn't work.

The problem seems to be that at design time, the implementation class can't
be cast back to it's grandparent, while at run time it can.

Am I missing something?  The real project is severely crippled because of
this.  There is a lot of custom UI that make use of a plugin-style framework
like this.  I can't use the designer now!

Signature

===>DavidC

David Creel - 14 Jan 2006 23:12 GMT
BTW - this is VS.NET 2005, using C#.  I doubt this is language-related though.
Signature

===>DavidC


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.