Example #1
0
 public static void Main()
 {
     try
     {
         AppDomain domain = AppDomain.CreateDomain("FooDomain");
         try
         {
             string assemblyName = Assembly.GetExecutingAssembly().FullName; // may be different assembly
             string typeName     = "Foo";
             IFoo   foo          = (IFoo)domain.CreateInstanceAndUnwrap(assemblyName, typeName);
             foo.DoGood();
             foo.DoBad();
         }
         finally
         {
             AppDomain.Unload(domain);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Error: " + e.Message);
     }
 }