如何使Visual Studio突破线程中的例外?
In this sample code, when I call a()
, the debugger breaks in properly, and I can inspect all local variables and stack frames.
Now if I call b()
, I get a completely useless "exception was thrown at ..." where the stack is unraveled already:
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我复制了您的问题。尝试转到异常设置,然后在框上单击一次,以获取
常见的语言运行时异常
从此更改::
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:To this:
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.
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.