Serialization Exception
what is Exception "End of Stream encountered before parsing was completed." in the my code?
BinaryFormatter t = new BinaryFormatter();
MemoryStream n = new MemoryStream();
t.Serialize(n, j)开发者_JAVA技巧;
BinaryFormatter q = new BinaryFormatter();
MemoryStream x = new MemoryStream();
q.Deserialize(n);
After serializing the object to the stream, the stream's Position
is at the end.
Therefore, there is nothing more in the stream for the deserializer to read.
You need to rewind the stream, by setting n.Position = 0
.
精彩评论