Logging Block Exception Unloading AppDomain

Topics: Logging Application Block
Oct 30, 2007 at 8:07 PM
I am running into unhandled exceptions in my application that creates and executes code in created AppDomains. I create an AppDomain to host a plugin and if that plugin loads the Logging Block, then there is an exception after the AppDomain is unloaded.

I assume the static classes of the Logging Block are accessing the AppDomain after it is unloaded. I assume the Logging Block as the culprit because if I remove Logging code from the plugin, the exception does not happen.

I see the exception when running my unit tests in NUnit. It does not crash the test, but NUnit's status is that the test failed.

Is there a method to force the logging code to unload or "quit"?

Any help would be appreciated.


Brian R.
Oct 31, 2007 at 12:45 PM
Hi Brian,

There's a Logger.Reset() method but it's internal. What's does the exception you get look like?

Oct 31, 2007 at 5:18 PM
I am getting a System.AppDomainUnloadedException as I have already called 'AppDomain.Unload(targetDomain)' and then receive this exception with no stack trace whatsoever. The exception is thrown from another thread and not when I call AppDomain.Unload.

The static class nature of the logger makes me think it is still lingering aroudn and trying to reference code that was in that unloaded AppDomain. If I make one simple Logger.Write call in the target app domain, I see this exception. If I comment out the code, it is not thrown.