在程序中抛出的任何异常强制中断 [英] Force break on any exception thrown in program

查看:165
本文介绍了在程序中抛出的任何异常强制中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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.

这篇关于在程序中抛出的任何异常强制中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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