在程序中抛出的任何异常强制中断
在C#编写代码时,我不喜欢处理异常,因为它可以更容易地找出错误的原因。但是,我无法给任何一个不处理异常的程序。
When coding in C# I like not to handle exceptions because it makes it easier to figure out where and why things went wrong. However, I can't give anyone a program that doesn't handle exceptions.
我可以以某种方式强制Visual Studio打破每个异常,包括在try / catch块?
Can I somehow force Visual Studio to break on every exception, including those thrown inside try/catch blocks?
VS2015及更高版本:进入Debug> Windows> Exception Settings,勾选公共语言运行时异常(在Break Throwwn列标题下方)。
VS2015 and later: Go into Debug > Windows > Exception Settings and check the tick box against Common Language Runtime Exceptions (below the 'Break When Thrown' column header).
VS2013及更早版本:进入Debug> Exceptions并检查抛出框是否符合通用语言运行时异常。
VS2013 and earlier: Go into Debug > Exceptions and check the Thrown box against Common Language Runtime Exceptions.
您可能会以这种方式获得一个批次的噪音,因为这样也会打破在图书馆或框架本身内部抛出的异常。
You may get a lot of noise this way though, as this will also break on exceptions thrown in libraries or inside the framework itself.