Sunday, March 23, 2008

How to mark a method to avoid tracing in debugger.

When we want to avoid tracing a method in debugger, we can add attribute DebuggerStepThroughAttribute. If a method will be marked by the attribute, then debugger (Visual Studio) will not trace into the method (by command "Step Into") and breakpoint will not be enabled in body of the method.

Sample:

SampleDebuggerStepThroughAttribute

Method Method_not_Debugable() is marked by attribute DebuggerStepThroughAttribute and we cannot trace it by debugger's command "Step into" and set breakpoint inside the method.

Output:

OutputSampleDebuggerStepThroughAttribute

Reference:

DebuggerStepThroughAttribute Class

Source file of the sample

 

No comments: