Object events after serialization (SQL Server session state)

Object events after serialization (SQL Server session state)

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


geordiepaul posted on Wednesday, May 16, 2007

Some of out Parent objects have methods that are fired when a child list changed. Simply done by subscribing the to the ListChangedEvent of the child list.

In our web environment the parent object is cached on session and all works fine with InProc session state but when changing to SQLServer which serializes the object none of the event fire once the object has been retrieved.

Is this something I have to handle myself? i.e. rewire the events on deserialization or should it work?

RockfordLhotka replied on Wednesday, May 16, 2007

In current versions of the framework (1.53 and 2.1.4) the events should be re-hooked automatically on deserialization.

Skeeboe replied on Wednesday, May 16, 2007

Rocky the onlistchanged and onisdirty changed events are not working for remoting in 1.53 compiled in .net 2.0. See:
http://forums.lhotka.net/forums/thread/9575.aspx

RockfordLhotka replied on Wednesday, May 16, 2007

That is quite possible, but I am not making any attempt to port or support CSLA 1.x under .NET 2.0.

 

I know a couple issues have been discovered, but I simply don’t have the ability to deal with the possible variants of where everything may be run as time goes on. What support I provide is for 1.53 on .NET 1.1 and 2.x on .NET 2.0 (and soon 3.0 on .NET 3.0).

 

Microsoft changed the way remoting works from 1.1 to 2.0, and so it doesn’t entirely surprise me that the older CSLA code doesn’t work properly. Odds are that some of the CSLA 2.0 code/techniques could be back-ported into 1.53 to create some sort of 1.53-for-.NET-2.0 hybrid.

 

Rocky

 

 

From: Skeeboe [mailto:cslanet@lhotka.net]
Sent: Wednesday, May 16, 2007 9:22 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Object events after serialization (SQL Server session state)

 

Rocky the onlistchanged and onisdirty changed events are not working for remoting in 1.53 compiled in .net 2.0. See:
http://forums.lhotka.net/forums/thread/9575.aspx

geordiepaul replied on Thursday, May 17, 2007

RockfordLhotka:
In current versions of the framework (1.53 and 2.1.4) the events should be re-hooked automatically on deserialization.

This does not seem to be working for us, we are using the latest version 2.1.4 we have had to override the OnDeserialized method and re-hook the events which then fixes everything.

An example of what we have would be

public class Parent : BusinessBase<Parent>
{
         private ChildCollection
m_Collection;

         private void Collection_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
         {
         }

         [RunLocal()]
         protected void
DataPortal_Create(Criteria criteria)
         {
                  m_Collection = ChildCollection
.GetChildCollection();
                  m_Collection.ListChanged 
                  += new  System.ComponentModel.ListChangedEventHandler
   (Collection_ListChanged);
         }

}

public class ChildCollection : BusinessListBase<ChildCollection, ChildItem>
{
}

public class ChildItem : BusinessBase<ChildItem>
{
}

Would the events be re-hooked in this instance?

RockfordLhotka replied on Thursday, May 17, 2007

CSLA only manages event hookups between a collection and its children. Nothing else.

So if you have a parent object that hooks ListChanged, then you are entirely on your own - and yes, you would need to take care of the deserialiation case yourself.

geordiepaul replied on Thursday, May 17, 2007

Ok thanks just needed to know whether it was something I needed to handle or not.

Thanks for you help :-)

Copyright (c) Marimer LLC