.net - Track an instance in C#? -
this question has answer here:
is there way track single instace in c#/.net in visual studio while debugging? find useful sometimes.
another way @ breakpoints on instances rather code. therefore, every time instance accessed and/or modified execution stops , presented line of code accesses/modifies instance.
in c++ equivalence monitoring piece of memory instance located, or pointer instance. approach doesn't work managed code objects in .net moved around, therefore need equivalence pointers in c++.
i aware of weakreferences in c# not sure if of use while debugging?
edit1: question different "when debugging, there way tell if object different instance? " not interested in comparing 2 references, want access single object.
there's nothing i'm aware of out of box, vs support conditional breakpoints. 1 option to:
- place breakpoints on of methods on class you're interested in
- debug code through until first of these hit
- find hashcode of instance
- make of breakpoints coditional on
gethashcode() == hash code retrieved
- let application run on until breakpoint hit again
- look in call stack window see line of code calling method
a little clunky, work...
Comments
Post a Comment