Temporary logging in VS.NET 2008 using Tracepoints

I’m not sure whether this feature existed before VS.NET 2008 – it may even be common knowledge that has just passed me by. But I think it’s just as cool as hell!

In a source file if you create a breakpoint, you get offered a ‘When Hit…’ menu option.


When you click on that you get the following dialog box allowing you to create a breakpoint that does debug window logging!


you can get temporary (and very detailed) logging by selecting the ‘Print a message’ checkbox. You also have the option to run a Macro


There’s no limit to what you could do with this lot. And the beauty of it is that you don’t have to litter your code with unnecessary logging statements (especially in JS) unless you want to. So if you’re performing diagnostics on a problem function, you can add these tracepoints and get lots of info, and then with a Ctl-Sh-F9 you can remove them all without having to recompile.

Nice. You can also add it from the context menu under the breakpoint menu option as ‘insert a tracepoint’


2 thoughts on “Temporary logging in VS.NET 2008 using Tracepoints

  1. Corneliu Tusnea wrote this:

    AFAIK it was there even in VS2003 (they are named “Tracepoints”)

    Now there are some very cool tricks you can do with them. For example you can write in your trace {EIP = EIP + 4} so you can make the debugger “jump” over the next line of code. “+4” has to be the value of instructions for your next line of code but that’s easy to calculate that value.

    So basically you can (in a very easy way) “comment out” a line of code and have it not executed during your session without recompiling the code.
    There are other tricks you can do in there like make loops infinite, or early force of exit loops and basically anything you can do from the immediate window as a “one task” you can do it from here as a “recurring operation”.

Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: