Click to See Complete Forum and Search --> : debug c# with VS2008


kabilius
November 2nd, 2009, 10:16 AM
Hi all,

I am using .NET 3.5 with VS2008.

I have a variable mySize decared as follows

Size mySize = new Size(30, 30);


mySize was modified somewhere in the program, and I am trying to figure out where it was modified.
In C++, I could trying to put the memory address of the mySize into Visual Studio, and it will just break whenever the memory address is being modified. However, I am unable to find the memory address of mySize in C#.

Could someone tell me how to get the memory address of a variable in VS2008 C#?

Thank you,
kab

eclipsed4utoo
November 2nd, 2009, 01:39 PM
if you believe code is setting it to a different value, you can right-click on the variable --> Find All References .. and it will show you all code that references that variable. From there you should be able to see code that is modifying it.

As for getting the memory address of a variable like you talk about in c++, no idea.

kabilius
November 3rd, 2009, 01:56 PM
Hi eclipsed4utoo,

Thanks for the reply.
I guess "managed" code just doesn't allow us to have the kind of memory access I am looking for.

I set a break point in the SizeChange event, and got the problem solved.

Thank you,
kab

BigEd781
November 3rd, 2009, 02:55 PM
Hi eclipsed4utoo,

Thanks for the reply.
I guess "managed" code just doesn't allow us to have the kind of memory access I am looking for.
kab

You have no idea where an object may be at a given time. The garbage collector manages the heap and may move around things at will. So, watching an object's memory location has no value in this context (not that it wouldn't be nice).