Tracepoints in Visual Studio 2005

Posted: (EET/GMT+2)

 

If you are using Visual Studio 2005, you might have noticed that many features are enhanced and improved compared to the previous versions. Once example is debugging and especially breakpoints. With VS 2005, breakpoints don't necessary need to break anymore, instead you can convert them to useful tracepoints, which can for example log information about current method, thread ID/name, variable values, etc. without stopping the execution of your C# application.

To enable tracepoints, first add a regular breakpoint, right-click the red round button on the code editor margin, and select When Hit:

When you add a message to be printed into the dialog box that opens and you have the "Continue exection" checkbox checked, you have effectively created a tracepoint (a "non-breaking breakpoint"). Note how the red round button now becomes a red diamond. Tracepoints can be very useful ad-hoc debugging aids, when you don't want to write code to do logging. Use them.