working with multiple app domains

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreekanth
    New Member
    • Apr 2006
    • 1

    #1

    working with multiple app domains

    I have this interesting problem. I am creating multiple domains using AppDomain.Execu teAssembly. I created domains App1, App2 and App3 (in the same order). If I close App1, both App2 and App3 close immediately. If you close App2, it will close App3 but not App1. It won't affect App1 and App2 if I close App3. I think they are kind of having parent-child relation. I wonder how to avoid this. I want to close only A, not B and C.


    Thanks in advance.

    private int i = 0;

    private void button1_Click(o bject sender, EventArgs e)
    {
    MethodInvoker m = (MethodInvoker) delegate()
    {
    Evidence ev1 = AppDomain.Curre ntDomain.Eviden ce;

    AppDomainSetup domaininfo = new AppDomainSetup( );
    string appPath = Application.Exe cutablePath;

    i++;
    string appName = "App" + i.ToString();

    domaininfo.Appl icationName = appName;
    domaininfo.Appl icationBase = "file:///" + System.Environm ent.CurrentDire ctory;

    AppDomain d = AppDomain.Creat eDomain(appName , ev1, domaininfo);
    d.InitializeLif etimeService();

    d.ExecuteAssemb ly(@"C:\project s\WindowsApplic ation2\bin\Debu g\WindowsApplic ation2.exe");
    MessageBox.Show ("Closing " + appName);
    };
    this.BeginInvok e(m);
    }
Working...