Hi,
I have a class that is inherited from Panel. Because Panel is not
serializable, I have implemented the ISerializable interface on this class
and I can sucessfully save and load classes from disk by serializing and
deserializing with a binary formatter.
Now, I have another class that happens to contain an array[] of the above
classes... when I attempt to serialize the array I get an error stating that
Panel is not serializable. Here is some code....
//the maze class serializes and deserializes fine...
[Serializable]
class Maze : Panel, ISerializable, ITreeObject, ICustomTypeDescriptor
{
string mazeName;
public void GetObjectData(SerializationInfo info, StreamingContext
ctxt)
{
info.AddValue("Name", mazeName);
}
public Maze(SerializationInfo info, StreamingContext ctxt)
{
mazeName = (string)info.GetValue("Name", typeof(string));
}
}
//here is my parent collection...
[Serializable]
class MazeCollection : Panel, ITreeObject, ICustomTypeDescriptor
{
Maze[] mazes;
MazeCollection() {
mazes = new Maze[16];
}
public void GetObjectData(SerializationInfo info,
StreamingContext ctxt)
{
info.AddValue("mazes", mazes);
}
public MazeCollection(SerializationInfo info, StreamingContext
ctxt)
{
mazes = (Maze[])info.GetValue("mazes", typeof(Maze[]));
}
}
The wrapper class, fails when it is serialized... what am I missing?
thank you for any suggestions..