如何使Visual Studio突破线程中的例外?

发布于 2025-02-01 21:18:09 字数 444 浏览 2 评论 0原文

在此示例代码中,当我调用a()时,调试器会正确断开,并且可以检查所有本地变量和堆栈框架。 现在,如果我调用b(),我将获得一个完全无用的“例外是在...”中拆开的地方:

我该如何解决?

In this sample code, when I call a(), the debugger breaks in properly, and I can inspect all local variables and stack frames.
enter image description here
Now if I call b(), I get a completely useless "exception was thrown at ..." where the stack is unraveled already:
enter image description here

How can I fix this?

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

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

发布评论

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

评论(1

¢好甜 2025-02-08 21:18:09

我复制了您的问题。尝试转到异常设置,然后在框上单击一次,以获取常见的语言运行时异常从此更改:

“在此处输入图像描述”

sstatic.net/vwz3d.png “ 当我打开 all CLR异常时,设置为时,当投掷时,我会得到正确的断点。如果您达到相同的结果,则问题是默认情况下某些例外是禁用的。他们仍然投掷,只是不会闯入。作为启用所有这些功能的替代方法,您可以扩展条目,以确切查看哪些内容是禁用的,并在选择的情况下自定义设置。

编辑我还运行并确认了汉斯在评论中刚刚说明的内容,这总是随着.NET 6 Core Console应用程序而破裂。因此, new 问题似乎是您可以在弹出窗口中抛出此异常类型时 unbeck 中断,但是该设置被忽略了,并且无论如何它都破裂了。

I reproduced your issue. Try going to Exception Settings and click one time on the box for Common Language Runtime Exceptions changing from this:

enter image description here

To this:

enter image description here

On my test setup when I turn on all CLR exceptions to Break When Thrown I get the correct breakpoint. If you achieve the same result, the issue is that some exceptions have this disabled by default. They still throw, they just don't break. As an alternative to enabling all of them, you can expand the entry to see exactly which ones are disabled and customize the settings if you choose.

enter image description here

EDIT I also ran and confirmed what Hans just stated in his comment, that this always breaks with a .NET 6 Core console app. So the new issue seems to be that you can uncheck the break when this exception type is thrown in the popup, but that setting gets ignored and it breaks anyway.

enter image description here

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