Serialization sometimes tries to serialize more than it should!

  • Thread starter Thread starter Nate
  • Start date Start date
N

Nate

Has anybody else seen this with serialization?

I have some options for my application that I am serializing. The object is
serializable and otherwise serializes and deserializes fine. Sometimes
though, when I call the object.serialize method (of mine) the serializer
tries to serialize the form that I called this from as well as the object
itself.

I've tried various ways of getting around this:
(1) binformatter.serialize(oFSysObj, me)
(2) creating a temporary object of the same type, then manually going
through and coping property-by-property the settings from the object I want
to serialize to the temp object, and then called:
binformatter.serialize(oFSysObj, tempObject)

Still, only "sometimes" I will get an exception that says the form (that I
called the method from) does not have the "serializable" attribute set.

Why would the serialization try to serialize the form as well as the object,
I am explicitly keeping everything in the object.

Any ideas anybody?
 
Hi Nate,
I'm not sure that this is exactly the case, but serialization serializes the
whole object graph. So, it will serialize your objects as well as all others
that your object keeps refrences to. And that is ok. What is not OK and not
so obvious is that it will serialize all objects, which are using events
that your object exposes. So if you try to serialize a button, let say, this
will serialize the button and the form as long as the form has hooked on the
button's click event.
And the worse comes to worst if the event handler is private /in most of the
cases it is/ the serilization will throw an exception /I haven't tried with
v 1.1, though/, which will cancel it.

HTH
B\rgds
100
 
Back
Top