static void CurrentDomain_DomainUnload(object sender, EventArgs e) { Console.WriteLine("{0} Unloaded", ((AppDomain)sender).FriendlyName); GC.Collect(); GC.WaitForPendingFinalizers(); }