vs2010调试器异常视图

发布于 2025-01-08 16:43:32 字数 183 浏览 1 评论 0原文

我的vs2010抛出异常时显示此消息: Before

如何配置调试器以显示如下异常:

之后

谢谢!

My vs2010 shows this message when an exception is thrown:
Before

How can I configure the debugger to show exceptions like this instead:

After

Thanks!

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

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

发布评论

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

评论(1

羁客 2025-01-15 16:43:32

两者差别很大。当您显式地将调试器配置为在引发异常时停止时,您只会看到第一个。您可以使用“调试+异常”、“抛出”复选框来执行此操作。您并不经常使用它,实际上只有当您的代码包含太多 catch 语句,这些语句不适当地吞下异常并使代码行为异常时才使用它。它还具有显示您未编写的代码中的异常的技巧。单击“中断”按钮以使调试器向您显示详细信息。

只有当抛出异常并且没有 catch 块来捕获它时,您才会获得第二个屏幕截图,从而使其成为未处理的异常。这是一个致命错误,程序无法继续。调试器停止向您显示问题,否则调试会话结束。如果没有调试器,你的程序将会崩溃。这是“好的”类型,您可以通过省略 try/catch 块来获得它,这样您的程序就会在发生意外情况时终止。您需要为 AppDomain.CurrentDomain.UnhandledException 事件编写一个事件处理程序,以便用户至少知道出了什么问题。还有你。

Big difference between the two. You'll only see the first one when you explicitly configure the debugger to stop when an exception is thrown. You do so with Debug + Exceptions, Thrown checkbox. You don't often use this, really only when your code contains too many catch statements that swallow exceptions inappropriately and making the code misbehave. It also has a knack for showing exceptions in code you didn't write. Click the Break button to allow the debugger to show you the details.

You'll only get the second screenshot when an exception is thrown and there is no catch block to catch it, making it an unhandled exception. That's a fatal error, the program cannot continue. The debugger stops to show you the problem, it is otherwise the end of the debugging session. Without a debugger your program will crash. This is the 'good' kind, you get it by omitting try/catch blocks so your program terminates when something unexpected happens. You will want to write an event handler for the AppDomain.CurrentDomain.UnhandledException event so the user at least has an idea what went wrong. And you for that matter.

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