[Mono-list] Serialization Compatability and workaround question
Fri, 28 Feb 2003 09:25:18 -0500
Thanks Lluis that is exactly what I need ;)
From: Lluis Sanchez [mailto:email@example.com]
Sent: February 28, 2003 5:30 AM
To: firstname.lastname@example.org; email@example.com
Subject: Re: [Mono-list] Serialization Compatability and workaround
> If I create a replacement for the Image object - how can I make sure
> correctly deserialize from a form that was created using .NET?
> ie How do I deserialize to my image object from the ms image object.
Image implement ISerializable, which means that to serialize the data of
Image, the serialization formatter will call
ISerializable.GetObjectData(SerializationInfo info, StreamingContext
context). SerializationInfo is like a dictionary where you store the
be serialized. You should use the same keys and value types that MS.NET
uses. The order desn't matter.
To deserialize an Image, the formatter calls a special constructor that
Image needs to implement (it can be private). This constructor must have
following signature: Image (SerializationInfo info, StreamingContext
context). In SerializationInfo you'll find the data that you need to
reconstruct the image.
> Without digging into the classes, does my Image object need to have
exact same members both private and public?
It would be needed if Image used default serialization, but it does not.
can use whatever variables you want. Only what you put in
will be serialized.
> Is it just variables I need to worry about (because that's all that
get serialized)? Must the order or
> the names be the same?
Order doesn't matter because the name of the fields are serialized
with the data.
> I will certainly be doing a different implementation to Microsofts -
additional variables -
> If I mark these not to be serialized?
This is a solution when using default serialization.