views:

168

answers:

3

I just learned about $exception in the VS.NET watch window for .NET yesterday. This shows the current exception that has been thrown and is a big time-saver in not needing to find the little exclamation point icon and hover over it.

What other special variables are there in the watch window?

(Note: this question is about .NET, not C++.)

+5  A: 

If you right click any variable in the Watch window, you can create an Object ID. This will give you a number, e.g. the first object ID will be 1#.

The Object ID represents the specific instance. The instance can thus be watched in the Watch window just like a regular variable, but you can keep watching the instance even when local reference go out of scope. When it eventually gets garbage collected you will lose access to it.

Brian Rasmussen
+1  A: 

Using "@err" will display the value of GetLastError() and "@err,hr" displays the error message.

Fredrik Ullner
This is from C++ land (along with @eax, @clk, and so on), but I was hoping to get more from the .NET world.
Scott Bilas
+1  A: 

The $user pseudo variable is the only other documented one. In VS2010, the VB.NET debugger acquires some new ones.

Hans Passant
The $dynamic that VB supports also works in C# via ", dynamic". Not sure about the rest, though.http://msdn.microsoft.com/en-us/library/dd998308%28v=VS.100%29.aspx
Scott Bilas
I saw something else in that MSDN article. It supports automatic dynamic view of __ComObject. That's awesome.
Hans Passant