Accessing out of scope Objects from Immediate Window in Visual Studio

Accessing out of scope Objects from Immediate Window in Visual Studio

In the previous post, you have seen how we can use Object ID during debugging to access any objects that are out of scope. This post talk about a bit extension of the same feature. You can also access these objects using the created Object ID ( Created from Watch Window) from the Immediate Window.

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

Consider you have following set of object and you have created an Object ID for the same – $1 .

1c1

Now, when it goes out of scope / or you closed the watch window and if you want to access the same in the Immediate Window, you can still access it.

Just type the Object ID associated with the object inside Immediate Window.

As you can see from the following screen shot, the current value of the “student”  and you can access the old out of scope value in Immediate Window.

image

You can access any variables or methods from the object Id’s as ((ClassName)ObjectID#).Properties or ((ClassName)ObjectID#).Method().  As per our example we can access Roll for that Object as shown in below.

image

 

Hope this small tricks helps.

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

2 Comments to “Accessing out of scope Objects from Immediate Window in Visual Studio”

Comments are closed.