我希望Visual Studio在处理异常发生时中断(即我不只是想看到“第一次机会”消息,我想调试实际的异常)。
例:我希望调试器在异常时中断:
try
{
System.IO.File.Delete(someFilename);
}
catch (Exception)
{
//we really don't care at runtime if the file couldn't be deleted
}
我偶然发现了这些Visual Studio的笔记。NET:
1) In VS.NET go to the Debug Menu >> "Exceptions..." >> "Common Language Runtime Exceptions" >> "System" and select "System.NullReferenceException" 2) In the bottom of that dialog there is a "When the exception is thrown:" group box, select "Break into the debugger" 3) Run your scenario. When the exception is thrown, the debugger will stop and notify you with a dialog that says something like: "An exception of type "System.NullReferenceException" has been thrown. [Break] [Continue]" Hit [Break]. This will put you on the line of code that's causing the problem.
但是它们不适用于Visual Studio 2005(在Debug菜单上没有例外选项)。
有人知道在Visual Studio中“当抛出异常时”组框的哪里找到这个选项对话框,其中有“进入调试器”的选项吗?
更新:问题是我的调试菜单没有异常项。我自定义菜单手动添加它。