I know we have Watch to monitor a variable in Debug mode, you can the variable changing, removed, or being assigned to another object.
But what I mean is to monitor a centain object states in memory.
Say I have a method that will receive an object and assign into a variable
i.e:
void DoSomething(object anObject){
object tempObject = anObject;
}
This method will be called more than 1 times.
If I use Watch on this tempObject, the tempObject in Watch will keep on changing when the new assigned object value.
What I interest here, is to only Watch this anObject instead. Say on the 2nd Call to this method, I found out this anObject has centain parameter is incorrect, I want to trace this object, to see when will this incorrect parameter changed back to a correct parameter. (Even out of scope).
How can I do that? Or is it possible to do it in Visual Studio?
Because right now I am having similar problem, I have a centain object I see it got disposed, but somehow somewhere is being used again and its said is not disposed. Using Watch I have no idea if that’s the same object I have been watching.
I hope I made this clear.
Try holding a WeakReference to the object in question and watch it. From there you can see if the target of the
WeakReferenceand the object in question are in fact the same object.