如何诊断和最小化或防止AppDomainUnloadedException
?
在涉及PLINQ的长时间(> 10s)测试之后,NUnit 2.5.2始终抛出AppDomainUnloadedException
。
早在2008年7月,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.
我尝试了许多解决方法,包括:
/domain:None
作为NUNit参数legacyUnhandledAppDomainPolicy
删除nunit-console.exe.config
元素我无法将NUnit降级到reduce the odds of the race condition,因为我需要PLINQ来使参数测试更快。没有问题的NUnit版本不支持参数测试。
最佳答案
根据this PLINQ Task Manager thread on the MSDN forums,您的问题应该得到解决;在.NET Framework的最新版本中,PLINQ的任务管理器已在AppDomain卸载时彻底关闭。
.NET 4或4.5是否仍遇到此问题?
关于.net - NUnit测试PLINQ代码后,如何防止AppDomainUnloadedException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1340187/