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:
/domain:None
as an NUNit argumentlegacyUnhandledAppDomainPolicy
element from nunit-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.
According to this PLINQ Task Manager thread on the MSDN forums, your problem should be solved; with the latest release of the .NET framework, PLINQ's Task Manager has been to shutdown cleanly on AppDomain unload.
Are you still running into this problem with .NET 4 or 4.5?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With