Serialization - problems with inheritance and containment

matahijau

Newcomer
Joined
Dec 7, 2004
Messages
1
I have a class MyForm : System.Windows.Forms.Form which I have marked as Serializable and I made implement ISerializable. It contains one instance of a class MyPanel : System.Windows.Forms.Panel, also implementing ISerializable. There is one more level of containment, as the MyPanel class contains one instance of a class MyPicBox : System.Windows.Forms.PictureBox (also implementing ISerializable).

So containment is illustrated by…
MyForm > MyPanel > MyPicBox

The instance of MyPicBox contains a string and an Image which I want to serialize. How do I do this? I know the specifics that are common to a normal serialization process (like using a formatter). It’s the hierarchal containment that is confusing me. The serialization process must start in MyForm, even though there is really nothing to serialize until we burrow down into MyPicBox. I can’t just stick the [Serializable] attribute on each class and let if fly because they inherit from nonserializable base classes of the Framework. If you have any insight I would greatly appreciate your advice. Thanks!

Collin Lourie
 
How are you implementing ISerializable in each of the classes?
If the MyPicBox implements ISerializable then you should be able to call it's implementation from the MyPanel's implementation to simply delegate the task down to the nested members.
 
Back
Top