mahdi_jeddi Posted February 15, 2005 Posted February 15, 2005 Is this a bug in .Net? I couldn't find something on web to help me. Please help. I'm writing a B+ Tree and I want to serialize the B+ Tree instances to file for later loading. I've followed the tutorials step by step: making all nedded classes [serializable], and using this code to Serialize the object: FileStream treeFileStream = new FileStream(treeFilePath, FileMode.Create); BinaryFormatter serializer = new BinaryFormatter(); serializer.Serialize(treeFileStream, this); The problem is here when I try to deserialize the object: FileStream treeFileStream = new FileStream(filePath, FileMode.Open); BinaryFormatter serializer = new BinaryFormatter(); BPlusTree loadedBPlusTree = (BPlusTree)serializer.Deserialize(treeFileStream); It sometimes throw this exception: String cannot have zero length. and some other time this one: Binary stream does not contain a valid BinaryHeader, 123 possible causes, invalid stream or object version change between serialization and deserialization. Thank you. Quote
Administrators PlausiblyDamp Posted February 15, 2005 Administrators Posted February 15, 2005 (edited) Any chance you could attach a small test project that exhibits this behaviour? Failing that is this problem occurring between runs of you app or when you try to serialize / de-serialize within a single run? If the latter you may want to check you are closing down all the files when you have finished with them. Edited March 1, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mahdi_jeddi Posted February 18, 2005 Author Posted February 18, 2005 (edited) I attached the entire solution Any chance you could attach a small test project that exhibits thi behaviour? Failing that is this problem occurring between runs of you app or when you try to serialize / deserialize within a single run? If the latter you may want to check you are closing down all the files when you have finished with them. I'm sure that there is no problem with the open/close files, Because deserializer is the one that throws the exception not the filestream. Maybe the hierarchy of my BPlusTree is too complicated. But if this is the case shouldn't serializer throw some exception? I attached the entire solution.BPlusTree.zip Edited February 19, 2005 by PlausiblyDamp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.