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 / .NET Framework / New Users / December 2004

Tip: Looking for answers? Try searching our database.

Dynamically loading controls -> loosing type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Zuber - 13 Dec 2004 18:17 GMT
Hi NG

We want to load controls dynamically and create them on a WinForm. Doing so,
we seem to loose type information. The scenario is as follows: The class
MANCombobBox inherits from ComboBox and implements the interface
IReportDataSource.

This works:
Control c = new MANComboBox(); //MANComboBox inherits from ComboBox and
implements the interface IReportDataSource

MessageBox.Show( (c is IReportDataSource).ToString() ); //This
returns/displays true

Here we have the problem:
Assembly asm = Assembly.LoadFile("LookupControls.dll"); //loads the dll
which contains the MANComboBox control

Control control = (Control) asm.CreateInstance(fullControlName); //Pointing
with the mouse onto control, the IDE tells me, that control contains
something of type MANComboBox

MessageBox.Show( (control is
MAN.Framework.Win.MANReportLookupControls.MANComboBox).ToString() );
//returns false

Intellisense even shows me the methods of the implemented interface
IReportDataSource but during runtime an invalid cast exception is thrown.

Any hints?

Thanks for all the help we get

Cheers

Peter
Mattias Sj?gren - 13 Dec 2004 20:08 GMT
Peter,

>Any hints?

http://www.gotdotnet.com/team/clr/LoadFromIsolation.aspx
http://blogs.msdn.com/suzcook/

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


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.