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

 Software development is an art.

The ?? operator C# operator returns the left side if it is not null. It returns the right side if the left side is null. It is very handy in situations where you can expect a value to be null but you want to use a default value if it is. Here is an example:

        string valueCouldBeNull = GetTheValue() ?? "The default value";
        Console.WriteLine("The result is " + valueCouldBeNull);

When assigning nullable types to non-nullable types you can avoid compile-time exceptions using the ?? operator.

kick it on