为什么Visual Studio 2010不会处理未处理的异常? [英] Why doesn't Visual Studio 2010 break on an unhandled exception?

查看:189
本文介绍了为什么Visual Studio 2010不会处理未处理的异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的程序中出现异常,并且它是未处理的时候,我期望调试器在我的程序中打破,并告诉我问题是什么。这不会发生。相反,我的程序只是退出,调试停止。

When there is an exception thrown in my program, and it is unhandled, I expect the debugger to break in my program and show me what the problem is. This doesn't happen. Instead, my program simply exits, and debugging stops.

如果我看看调试输出,我可以看到我的例外:

If I look at the debugging output, I can see my exception:


在System.dll中发生类型为
'System.NullReferenceException'
的第一次机会异常

A first chance exception of type 'System.NullReferenceException' occurred in System.dll

我正在使用Visual Studio 2010,Visual Basic,编写一个简单的WinForms应用程序。在这种情况下,代码并不重要,它发生在目前为止我已经看到的任何异常。

I am using Visual Studio 2010, Visual Basic, writing a simple WinForms app. The code doesn't matter in this case... it happens with any exception that I've seen so far.

在线阅读关于执行调试菜单并单击例外并启用打破未处理的用户异常,但我看不到此选项。我认为这个建议是VS2008,不再适用。

I've read a lot online about doing to the Debug menu and clicking Exceptions and enabling "break on unhandled user exception", but I don't see this option. I think this advice is for VS2008, and is no longer applicable.

我还应该注意到,我没有运行任何单元测试。我从来没有设置过。但是,我看过单位测试人员吞下了我的例外吗?

I should also note that I'm not running any unit tests. I have never set them up. However, I have read that perhaps the unit tester is swallowing my exceptions?

请告诉我如何改变Visual Studio的行为,所以我可以追踪这些未处理的

Please advise me on how to change the behavior of Visual Studio, so I can track down these unhandled exceptions.

感谢您的时间。

推荐答案

可能不在菜单中,您可以通过自定义菜单并将项目添加到调试菜单来修复。

The item may not be in the menu, which you can fix by customising the menu and adding the item to the debug menu.

您还应该可以进入例外菜单使用CTRL + ALT + E

You should also be able to get to the exceptions menu using CTRL + ALT + E

您需要勾选公共语言运行时异常(CLR)的Thrown列中的框。

You need to tick the box in the "Thrown" column for Common Language Runtime exceptions (CLR)

这篇关于为什么Visual Studio 2010不会处理未处理的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆