In a simple console app, I created a separate AppDomain (name: ad2) to do some work. In this AppDomain, I created a separate worker
thread and deliberately put the thread to sleep for long time (2 mins) in the Finally block.
I also subscribed to the ad2’s Unload event to do some logging.
Immediately after calling the worker method, I called the AppDomain.Unload(ad2) in the main thread. Because of the long Thread.Sleep()
in the worker thread finally block, a CannotUnloadAppdomainException was thrown when calling AppDomain.Unload(ad2).
View Complete Post