What special variables available in Visual Studio watch window in .NET?

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 then 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.


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


Supported Pseudovariables in Visual Studio for .NET debugging:

  • $exception: Displays information on the last exception. If no exception has occurred, evaluating $exception displays an error message. In Visual C# only, when the Exception Assistant is disabled, $exception is automatically added to the Locals window when an exception occurs.
  • $user: Displays a structure with account information for the account running the application. For security reasons, the password information is not displayed.

The following only apply to Visual Basic:

  • $delete or $$delete: Deletes an implicit variable that was created in the Immediate window. The syntax is $delete, variable or $$delete, variable.
  • $objectids or $listobjectids: Displays all active Object IDs as children of the specified expression. The syntax is $objectid, expression or $listobjectids, expression.
  • $N#: Displays object with Object ID equal to N.
  • $dynamic: Displays the special Dynamic View node for an object that implements the IDynamicMetaObjectProvider. Interface. The syntax is $dynamic, object. This feature applies only to code that uses .NET Framework version 4. See Dynamic View.

@ERR ;Last error value,the same value returned by the GetLastError() API function

@TIB ;Thread information block for the current thread

@CLK ;Undocumented clock register; usable only in the Watch window

@EAX, @EBX, @ECX, @EDX, @ESI, @EDI, @EIP, @ESP, @EBP, @EFL ;Intel CPU registers

@CS, @DS, @ES, @SS, @FS, @GS ;Intel CPU segment registers

@ST0, @ST1, @ST2, @ST3, @ST4, @ST5, @ST6, @ST7 ;Intel CPU floating-point registers