Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 424
scobi Avatar asked Mar 04 '10 19:03

scobi


2 Answers

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.
like image 70
IInspectable Avatar answered Oct 11 '22 21:10

IInspectable


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.

like image 25
Brian Rasmussen Avatar answered Oct 11 '22 22:10

Brian Rasmussen