Object Duplicity Issue - Please Help!!

Object Duplicity Issue - Please Help!!

Old forum URL: forums.lhotka.net/forums/t/6109.aspx


honus posted on Thursday, January 08, 2009

I have a Windows Forms application, that is using CSLA 3.0.2.0, and I am using Remoting.  I am noticing some wierd object behavior if I open the same form with two instances of the same object, although the data in the objects is different.

To outline my problem, here is an example:

Form1 is opened with Object1.  Object1 is of type A.  Object1 is populated with data for Person1.  No changes are made to Object1.  This instance of Form1 is left open.

Another instance of Form1 is opened with Object2.  Object2 is also of type A.  Object2 is populated with data for Person2.  Changes are made to Object2.  Object2 is saved and this instance of Form1 is closed.

Back to the original instance of Form1 with Object1.  Object1 is now dirty, although no changes have happened to it.

So, you can see the problem I am having.  I am leaning towards it being a threading problem, but I am not sure.  Can anyone provide some advice?

ajj3085 replied on Friday, January 09, 2009

Sounds like something in your code is using a static variable when it shouldn't be. 

honus replied on Friday, January 09, 2009

Could you provide a little bit more information?  I have scoured my entire solution, and I cannot find any 'static' declaration.  However, I do have ReadOnly properties in my object, and I read somewhere that ReadOnly properties are used as static.  Is this the problem?

I am really confused what static properties would have anything to do with the problem I am experiencing.

honus replied on Friday, January 09, 2009

Actually, I found that I declared a Shared instance of my object in the form, and I am guessing that is the problem.

ajj3085 replied on Friday, January 09, 2009

Sorry, I assumed you were using C#... but it seems you're using VB.  Yes, a Shared variable in VB would be a problem.

honus replied on Friday, January 09, 2009

No problem, your post actually got me thinking in the right direction, so thanks!

Copyright (c) Marimer LLC