tags:

views:

420

answers:

1

I'm trying to pass a business object from one WinForm to another WinForm for modification, and then repopulate the text boxes, etc. on the first form with the updated values.

However, it seems that the object values set in the second form are not "sticking" when the code control returns to the first form.

Is there a way to view the memory location of an object in VB.NET? I want to first make sure that the object variable on the second form is pointing to the same memory address as the object on the first form. Then I can take it from there.

In a separate VB project, I passed a simple object to a second form, modified the values, and re-displayed the object's values on the first form. It worked fine. In my real app, I'm passing an object that is a property of another object, which may be why it isn't working.

SOLUTION: The problem was that I was using a DeepCopy() function that I found to simplify copying the properties of one object to another. Removing that function and manually setting the values to the passed object on the second form (ex. obj.property1 = searchResult.property1) makes everything behave as expected.

+3  A: 

You cannot see the memory address of an object in VB.NET.

Could you show us a bit of code? Maybe we can spot the error.

What kind of object are you passing around? If the object is a value type, this will not work (declared with Structure instead of Class).

Denis Troller
I was just about to say that. In .NET bjects normally behave as you describe that you want, HardCode. Some code will help put the finger on what's happening.
Fredrik Mörk