NUnit 测试 PLINQ 代码后如何防止 AppDomainUnloadedException?

发布于 2024-08-03 16:26:04 字数 869 浏览 5 评论 0原文

如何诊断并最小化或防止 AppDomainUnloadedException

在涉及 PLINQ 的长时间(>10 秒)测试后,NUnit 2.5.2 始终抛出 AppDomainUnloadedException

早在 2008 年 7 月,Stephen Toub 就说过

是的,调度程序在 CTP 不能很好地处理线程中止,这经常导致 当域中存在实时调度程序时,进程会崩溃 关闭(因为 AppDomain 关闭会导致所有线程中止) 具有该域中的堆栈帧的线程)。我们正在努力强化 这是为了将来的版本。

我尝试了许多解决方法,包括:

  • 在单独的方法中运行测试以消除杂散引用
  • /domain:None 指定为 NUNit 参数
  • 中删除 legacyUnhandledAppDomainPolicy 元素>nunit-console.exe.config

我无法将 NUnit 降级到 减少竞争条件的可能性,因为我需要 PLINQ 来使我的参数测试更快。没有问题的 NUnit 版本不支持参数测试。

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Saygoodbye 2024-08-10 16:26:04

根据 此 PLINQ 任务管理器线程在MSDN论坛上,你的问题应该可以解决;使用最新版本的 .NET 框架,PLINQ 的任务管理器已在 AppDomain 卸载时彻底关闭。

您在使用 .NET 4 或 4.5 时是否仍然遇到此问题?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文