Reading the memory address of an object
I am trying to pass a business object from one WinForm to another WinForm for modification, and then re-populate the text boxes, etc. in the first form with updated values.
However, it seems that the object values set in the second form do not "stick" when code control returns to the first form.
Is there a way to view the memory location of an object in VB.NET? First, I want to make sure that the object variable in the second form points to the same memory address as the object in the first form. Then I can take it from there.
In a separate VB project, I passed a simple object to the second form, changed the values, and re-rendered the values of the objects in the first form. It worked fine. In my real application, I am passing in an object that is a property of another object and therefore it doesn't work.
SOLUTION: The problem was that I used the DeepCopy () function that I found to make it easier to copy the properties of one object to another. Removing this function and manually setting the values of the passed object in the second form (e.g. obj.property1 = searchResult.property1) makes everything behave as expected.
source to share