开发者

Serialization Exception

开发者 https://www.devze.com 2023-02-05 18:41 出处:网络
what is Exception \"End of Stream encountered before parsing was completed.\" in the my code? BinaryFormatter t = new BinaryFormatter();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消