Free Information Technology Magazines and eBooks

Saturday, April 18, 2009

.NET Debugging Tip: System.Diagnostics.DebuggerStepThrough()

One of the useful diagnostics tool that I often use on shared method or libraries that I don't want the debugger step into is the System.Diagnostics.DebuggerStepThrough(). The attribute tells Visual Studio IDE to skip the method while debugging through code. Below is a sample code the uses the attribute

In C#
[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
{
//Anything
}


In VB.NET


<System.diagnostics.debuggerstepthrough()>
Private Sub InitializeComponent()
'Anything
End Sub


The advantage of it is that you can save lot of time if you want to step
into your code at run time, but don't want to step into some
procedures unless they raise an exception.

0 comments: