Debugger tips VS.Net… Tracepoints

There are some nice things to know about Visual Studio.Net 2008 that can make life easier as a programmer. In the series ‘Debugger tips VS.Net’ I am gonna talk about the debug techniques VS.Net 2008 offers. Tracepoints is the subject of this post. A tracepoint is a breakpoint with a custom action associated with it. When the tracepoint is hit the custom action is performed. An example of such a action is writing a traceline to the output window.

How can you add a tracepoint? This is easy: go to the line of code where you want the tracepoint and press F9. This will add a breakpoint. The picture below shows a breakpoint.

 

Then right click the breakpoint and choose When hit from the menu that appears.

 

The When Breakpoint Is Hit dialog appears. In this dialog you can choose to print a message. This will add tracelines to the ouput window every time the tracepoint is hit. The message can be formatted and You can include programmatic information using DebuggerDisplayAttribute syntax. You can choose to run a macro when the tracepoint hits too. In the screenshot below the DumpStacks macro from the samples is picked. Select Continue Execution if you don’t want the tracepoint to break execution of your program.

 

 A tracepoint has its own icon. It is a red diamond in the margin of the code edit window.

 That was it.

kick it on DotNetKicks.com

 Software development is an art.