You can track Out of Scope Objects by assigning an Object ID during debugging in Visual Studio

By | February 17, 2016

Make Object ID”, you can consider it as an another hidden features of Visual Studio that can give you lot of flexibility during debugging.  When we set “Make Object ID” for an object,  we are informing the Debugger to keep track of that object no matter it’s within scope or out of scope for the current context.  You can create the “Object ID” either from Locals, Autos or from Watch Windows. Object ID is a integer number prefix by a dollar ($) sign. When we create Object ID for an particular object, Visual Studio Debugger  use an integer value to uniquely identify the object. This “Object ID” allows you to get the object details even if it is out of scope.





Let’s try to understand with a very simple example, where we are iterating a set of string through a loop. If you inspect the value of “item” for first time it should be “name1”.


Now If you move to next items, there is no way to get the value of previous items. In that case you can just select “Make Object ID” for the selected object.

NOTE : This is a very simple object, You can apply this for any complex objects as well.



Object the Object ID is created, a $ < Value> will be added with the item.

Must Read :  How to use out of scope object with in Conditional Breakpoint ?



Now, Let’s think you move to the next item in the collection.


Now, to access the previous value you can just type “$1” and it will show the value of previously tagged item associated with this object id.


Isn’t it cool.  Just think about you want to try to access one object’s values which is already went out of scope. This is super powerful feature during debugging; You can even object / values across methods / modules.

Think about this following add-on. Your context moved to anther method, and there if you try to access “item” values; you will get message that “item” does not exist.


But, instead, when you are trying to access it with object it you have it live.



Refer to my one of detailed post the same subject line  How to track an object which is Out of Scope while Debugging ?

3 thoughts on “You can track Out of Scope Objects by assigning an Object ID during debugging in Visual Studio

  1. Pingback: 19-02-2016 - Freaking friday link pack! - Magnus Udbjørg

  2. Pingback: Accessing out of Scope Objects from Immediate Window in Visual Studio

  3. Pingback: Visual Studio – Developer Top Ten for Feb 26th, 2016 - Dmitry Lyalin

Comments are closed.