Reputation: 2233
How can I prevent the debugger from entering my method when an exception is thrown, instead show the exception at the method's call site?
For example, if one's code causes an exception to be thrown from mscorlib, the debugger (obviously) does not take them into the non-user code to show the exception's source, only shows the exception at the call site.
In other words, this the default behavior:
and this is my desired behavior:
I have tried adding [DebuggerNonUserCode]
and [DebuggerStepThrough]
attributes to my Fail()
method, but no luck.
Upvotes: 7
Views: 327
Reputation: 101623
You need to decorate your method with DebuggerHiddenAttribute:
[DebuggerHidden]
public static void Fail() {
throw new Exception("Fail");
}
Upvotes: 6