473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Serializing collections of objects that implement ISerializable...

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..
Mar 10 '06 #1
0 2756

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jakob Bengtsson | last post by:
Hi, I have a form (which cannot be serialized). In the form's code I declare an object like this (never mind the object nor class name, it's for illustration only): Private WithEvents...
1
by: jeff | last post by:
I am using .NET remoting with a class,call it MyClass, that contains many other classes (say one of them is MySubClass). I have been able to successfully call functions from the MyClass, but when...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
0
by: Kenneth Baltrinic | last post by:
Is the following code correct for serializing a quasi-single class, that is a class that has a descreet (though more than one, so not a true singleton) number of static instances and no dynamically...
5
by: Mark Saccomandi | last post by:
Hi, I'm extending a serializable class I made. The new class adds some features that cannot be serialized automatically, this means that I have to implement the ISerializable interface for my...
1
by: Aidan Glendye | last post by:
Hi, I am trying to store various objects within session. Due to the site being hosted in a web farm we are going to have to use either State Server or SQL Server to persist the data in...
2
by: Simon | last post by:
I'm developing a new application and want to use serialization as a way to save my data. But as I add new variables to my classes, how will serializing cope with that? For example, suppose I have...
2
by: raj | last post by:
SORRY FOR CROSS POST JUST WANT TO GET AN ANSWER QUICKLY I know what interfaces are and what they used for etc. Today i am learning about serilization. I know to mark the class "serializable"...
1
by: =?Utf-8?B?a2thcnJl?= | last post by:
Hi all, We decided to clear the test db more frequently and I was asked to serialize som test objects to make sure our unit testing continues to work after clearing the db. Does anyone have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.