有没有办法继续在C#中的异常? [英] is there a way to continue an exception in C#?
问题描述
在一个意外的异常在你的程序中出现(在调试器)。有时候,你只是想跳过它,因为查杀方案在这一点上是不是继续的危害更大。或者你只是想继续,因为你更感兴趣的是另一个错误/缺陷
When an unexpected exception occurs in your program (in the debugger). Sometimes you just want to skip it since killing the program at that point is more harmful than continuing. Or you just want to continue since you were more interested in another error/bug
有一个选项/ compilerflag / secretswitch启用此?
Is there an option/compilerflag/secretswitch to enable this?
我的理解异常应马上解决,但有些情况(如我所描述),其中一个只是想跳过它的时间是
I understand exceptions should be resolved right away, but there are scenarios (like I described) where one just wants to skip it for the time-being
推荐答案
无需在code适当的catch块,你不能做到这一点,没有。但是,我不记得曾经想这样做:如果出现异常,你的code不知道如何真正处理,为什么你要继续吗?你是在一个糟糕的状态,在这一点上 - 不断将是危险的。
You can't do this without an appropriate catch block in your code, no. However, I can't remember ever wanting to do this: if an exception occurs which your code doesn't know how to genuinely handle, why would you want to continue? You're in a bad state at that point - continuing would be dangerous.
您可以给的,为什么你会希望在调试器会话继续的例子,但不是在生产code?
Can you give an example of why you'd want to continue in a debugger session but not in production code?
这篇关于有没有办法继续在C#中的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!