using System; public class Gen {} public class main { static object GenericFunc () { return new Gen (); } static void DoGenericStuff () { Console.WriteLine ("doing generic stuff"); GenericFunc (); } static void DoOtherGenericStuff () { Console.WriteLine ("doing other generic stuff"); GenericFunc (); } public static void Main () { // Create an Application Domain: System.AppDomain newDomain = System.AppDomain.CreateDomain("NewApplicationDomain"); // Load and execute an assembly: newDomain.ExecuteAssembly(@"generic-unloading-sub.2.exe"); DoGenericStuff (); // Unload the application domain: System.AppDomain.Unload(newDomain); DoOtherGenericStuff (); } }