I’ve made a “when hit, print a message” breakpoint in VS 2010. It works, but it only outputs to the VS “output” pane. Can I make it use my app’s console window?
I’ve tried:
Debug.Listeners.Add(new ConsoleTraceListener());
As well as:
var writer = new TextWriterTraceListener(System.Console.Out);
Debug.Listeners.Add(writer);
It is possible to print this message in your app console window, but for that you need to use the debugger evaluator:
Have a look at this code:
If you place a breakpoint on line 5: Console.WriteLine(i); with When Hit… property set to: {MessageFromDebugger(“message from address $ADDRESS”)} you should see in your console window:
What’s interesting is that you may pass arguments to your function that are valid in the calling scope as well as the special debugger variables (such as $ADDRESS, $PID, $CALLSTACK etc.). I observed though that special debugger variables are just placeholders and are replaced before submitting to your function, so remember to put them in double quotes, eg. {MessageFromDebugger(@”$CALLSTACK”)}