Reputation: 467
It's me again and I have another problem. Somewhere, I've found following code:
private T DeepDeserialize<T>(string fileName)
{
T returnValue;
using (FileStream str = new FileStream(fileName, FileMode.Open))
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
returnValue = (T)binaryFormatter.Deserialize(str);
}
return returnValue;
}
I've modified some classes today and now, it always throws an error, which could be translated like this: Before completing the analysis was detected ending stream
(I don't know the right translation, the error message is in my language, not in English)
I've tried to insert str.Position = 0;
between these two lines in using
, which I've found somewhere here, but it doesn't help.
Can someone help me to make it work again? I have no ideas what to do...
Upvotes: 0
Views: 54
Reputation: 1732
You have changed the binary layout of your files but most likely trying to deserialize old files. This is not gonna work. You have to serialize new versions first.
P.S. If you would consider versioning and custom formatter at early stages, you might be able to deserialize old data with new classes, depending on how drastic was your change
Upvotes: 1