scobi
scobi

Reputation: 14558

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

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++.)

Upvotes: 20

Views: 3534

Answers (5)

IInspectable
IInspectable

Reputation: 51511

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.

Upvotes: 12

IulianT
IulianT

Reputation: 420

@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

Upvotes: 3

Brian Rasmussen
Brian Rasmussen

Reputation: 116481

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.

Upvotes: 9

Hans Passant
Hans Passant

Reputation: 942348

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

Upvotes: 2

Fredrik Ullner
Fredrik Ullner

Reputation: 2166

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

Upvotes: 2

Related Questions