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 / Windows Forms / WinForm General / June 2006

Tip: Looking for answers? Try searching our database.

Setting Control's parent cross AppDomains

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Burgazon - 17 Jun 2006 06:13 GMT
Hi,

I encountered the following problem when trying to set control parent when
the control reside in a different AppDomain.

Here is the pseudo code descibing the problem:
pay attention that both controls inherits from UserControl which inherites
(indirectly)from MarshalByRefObject.

class Control1:UserControl
{

 AppDOmainSetup setup = new AppDomainSetup();
 //code that initialize the setup...

 AppDomain newAppDomain = AppDomain.CreateDomain("MyDomain",null,setup);
 
 Control c2 =
(Control)newAppDomain.CreateINstanceAndUnwrap(assemblyofcontrol2,Control2);
 
 this.Controls.Add(c2); //<===Exception (see message content below)

}

class Control2:UserControl //this control reside in a different assembly
{
}

The Exception message is:
exception the message is
The type System.Windows.Forms.Form+ControlCollection in Assembly
System.Windows.Forms, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 is not marked as serializable.

I tried to mark Control2 as Serializable but it didn't help :-(
Any suggestion?

Thanks,
Burgazon
Dmytro Lapshyn [MVP] - 17 Jun 2006 08:57 GMT
Hi,

Looks like the Control2 class communicates back to its parent collection,
and since the ControlCollection class is neither serializable nor derived
from MarshalByRefObject, this communication fails. I would really consider
moving away from multi-appdomain scenario in this case.

> Hi,
>
[quoted text clipped - 35 lines]
> Thanks,
> Burgazon
Burgazon - 18 Jun 2006 05:27 GMT
Thank you for the quick response.
I will try to change parts of  my architecture.
Thank you (again)

> Hi,
>
[quoted text clipped - 42 lines]
> > Thanks,
> > Burgazon

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.