Hi All,
I have a class that I have put [Serializable] above the constructor.
This class has an Arraylist of other objects of a different class which also has this heading.
I have a form that holds an ArrayList of objects that are the first class.
I can serialise using this:
And try to deserialise using this:Code:FS = new FileStream("C:/pop_queries.dat", FileMode.Create, FileAccess.Write); BinaryFormatter b = new BinaryFormatter(); b.Serialize(FS, common.ToArray()); FS.Close();
Query is the same type as the items held in the ArrayList common, which I convert array in the serialisation!Code:Query[] queriesFromFile; FS = new FileStream("C:/pop_queries.dat", FileMode.Open, FileAccess.Read); BinaryFormatter b = new BinaryFormatter(); queriesFromFile = (Query[])b.Deserialize(FS); FS.Close();
When I try to deserialise, I get the error:
Unable to cast object of type 'System.Object[]' to type 'ClassifyGUI.Query[]'.
Can anybody see where I have gone wrong?
Sam


Reply With Quote
