Fighting AppDomainUnloadedException and the PrivateBinPath problem

Today I'm fighting with two very annoying bugs in Ivonna.

The first one is, when you debug your tests, sometimes you get the AppDomainUnloaded exception ("Attempted to access an unloaded AppDomain"). That one has been annoying me for some time, so I decided to fix it. I have opened the thread list, found the thread that contained a call to AppDomain.Unload, switched to it, and checked the HttpRuntime instance. The _shutDownMessage field told me: "Change Notification for critical directories.\r\nbin dir change or directory rename\r\nHostingEnvironment initiated shutdown\r\nHostingEnvironment caused shutdown". So I watched the bin folder while running the test and discovered that Gallio copied the test project's config file to it, and then deleted it in the middle of a test. The runtime discovered that the bin folder contents has been changed and it should crash just in case.

Fixing it has been easy. I just stubbed the ReleaseResourcesAndUnloadAppDomain method using the CThru built-in Stub aspect.

The other bug is actually two bugs that manifest themselves only when combined. Ivonna creates an AppDomain for testing, and this AppDomain was having a duplicate PrivateBinPath (two identical paths actually). This was fine until I tried to test a FubuMVC based project that expected a single path in the PrivateBinPath property (actually it's a Bottles bug, but, since nobody uses multiple bin paths, the bug is probably not worth fixing). I won't bother you with technical details, but the good news is that Ivonna is now fully compatible with FubuMVC.

blog comments powered by Disqus

Latest blog posts

Powered by FeedBurner