ContextBoundObject And Serialization

  • Thread starter Thread starter sternr
  • Start date Start date
S

sternr

Hey,
I have ContextBoundObject dervied class, that holds a hashtable.
The hashtable contains objects from my DomainModel (Person,Employee
etc.).
All of this objects (my domain model and the ContextBoundObject) are
NOT marked as Serializable!

I send this ContextBoundObject to a ServicedComponent derived class
(ServerActivated) as a parameter and everything works perfectly well.

My question is, since the object has been shared between 2 processes, a
serialization process must'v taken place, even though I didnt mark my
objects as Serializable -- HOW???
Can someone please shed some light on there case for me,

Thanks ahead

--Rami
 
sternr said:
Hey,
I have ContextBoundObject dervied class, that holds a hashtable.
The hashtable contains objects from my DomainModel (Person,Employee
etc.).
All of this objects (my domain model and the ContextBoundObject) are
NOT marked as Serializable!

I send this ContextBoundObject to a ServicedComponent derived class
(ServerActivated) as a parameter and everything works perfectly well.

My question is, since the object has been shared between 2 processes, a
serialization process must'v taken place, even though I didnt mark my
objects as Serializable -- HOW???
Can someone please shed some light on there case for me,

I think that objects marked as Serializable, participate and control
serialization. Everything else gets default handling from the core
serialization code using reflection.
 
It took me quite sometime, but I found the answer!
ContextBoundObject inherits from MarshalByRefObject.
This object - when passed between 2 AppDomains (or processes for that
matter),
Will create a dynamic proxy for the object, which means that all the
data "inside" this obejct is never serialized\deserialized since it
never really leaves its appDomain!
The good thing is you get better performance and better scalability for
the objects hold inside the MarshalByRef-ed object - since they dont
need to worry about serialization,
And are called only on demand (kinda like lazy-load)
The bad thing is that every call to a property or a method to this
object will result in a remoting "conversation" EVEN IF IT'S IN THE
SAME PROCESS!, and it's also makes the consumer more connected to the
marshaled object!

Hope this will shed some light for some of you - it did for me ;)

--sternr
 
Back
Top