How can I diagnose and minimize or prevent AppDomainUnloadedException
?
NUnit 2.5.2 consistently throws AppDomainUnloadedException
after long (>10s) tests involving PLINQ.
Back in July 2008, Stephen Toub said:
Yes, the scheduler in the CTP doesn't handle thread aborts very well, which frequently causes the process to crash when a live scheduler exists in a domain being shutdown (since AppDomain shut down causes thread aborts on all threads with stack frames in that domain). We're working to harden this for a future release.
I've tried many workarounds, including:
- Running the test in a separate method to eliminate stray references
- Specifying
/domain:None
as an NUNit argument - Removing the
legacyUnhandledAppDomainPolicy
element fromnunit-console.exe.config
I can't backgrade NUnit to reduce the odds of the race condition, as I need PLINQ to make my parametric tests go faster. Versions of NUnit without the problem don't support parametric tests.