i am trying to load a Windows Form Assembly at run time to a seprate AppDomain.
I don't want that this Assembly to be loaded in the Caller Domain, so i used the metho
CreateInstanceFromAndUnwrap instead of AppDomain.Load(..
// I am passing the Control's parent through the constructor argumen
Object[] args1 = new Object[] {this}
AppDomainSetup info = new AppDomainSetup()
info.ApplicationBase = "file:///" + System.Environment.CurrentDirectory
AppDomain MyDomain = AppDomain.CreateDomain("MyDomain", null, info)
MyControl.MyControl Ctrl = (MyControl.MyControl) MyDomain.CreateInstanceFromAndUnwrap("D:\Test\MyControl.dll",MyControl.MyControl
false,BindingFlags.Public,null,args1,null,null,null)
But when i do this i get an exception thrown "Constructor on type MyControl.MyControl not found
What should be cause of this issue?

If i try to use the CreateInstanceFromAndUnwrap using the two parameters just the assembly and type, the functio
returns me the control object. But when i try to set the Parent of the control using the followin
code
Ctrl.Parent = this

then system throws an 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

What am i doing any thing wrong in this both scenarios
Or is it advisable to have a design where i can load my Windows Forms Assemblies in to a seprat
Domain and use, and later unload it

Any body please help....

RE: Usage of AppDomain.CreateInstanceFromAndUnwrap method by jchREMOVE

jchREMOVE
Thu May 06 03:41:05 CDT 2004

Hi Vineeth

I have tried something similar but I never succeeded in loading Windows Forms in another AppDomain. I don't know if it is possible. By the way, I believe that your code MyControl.MyControl Ctrl = (MyControl.MyControl) MyDomain.CreateInstanceFromAndUnwrap(...) will load the assembly into both the new AppDoamin and the calling AppDoamin. Is this what you want

Regards, Jakob


RE: Usage of AppDomain.CreateInstanceFromAndUnwrap method by jchREMOVE

jchREMOVE
Thu May 13 03:21:09 CDT 2004

Hey Vineeth

Sorry for my late reply

I do not think it is possible to load child forms into another AppDomain. I think it will fail everytime you try to set the Form.Parent property. I think it will be possible if you don't set the Form.Parent property but then the forms will be independent on the main form. This means you cannot use this scenario for MDI applications where the child forms are loaded into separate AppDomains

If you find a solution please let me know :-

Regards, Jakob.