Execute an Assembly in a Different Application Domain - CSharp Custom Type

CSharp examples for Custom Type:AppDomain

Description

Execute an Assembly in a Different Application Domain

Demo Code

using System;//from w  w  w  .  j a va 2 s  .  com
class MainClass
{
   public static void Main(string[] args)
   {
      if (AppDomain.CurrentDomain.FriendlyName != "NewAppDomain")
      {
         AppDomain domain = AppDomain.CreateDomain("NewAppDomain");
         domain.ExecuteAssembly("Recipe03-06.exe", args);
      }
      foreach (string s in args)
      {
         Console.WriteLine(AppDomain.CurrentDomain.FriendlyName + " : " + s);
      }
      if (AppDomain.CurrentDomain.FriendlyName != "NewAppDomain")
      {
         Console.WriteLine("\nMain method complete. Press Enter.");
      }
   }
}

Result


Related Tutorials