1

什么是异常“在解析完成之前遇到流结束”。在我的代码中?

BinaryFormatter t = new BinaryFormatter();
MemoryStream n = new MemoryStream();
t.Serialize(n, j);

BinaryFormatter q = new BinaryFormatter();
MemoryStream x = new MemoryStream();
q.Deserialize(n);
4

1 回答 1

3

将对象序列化为流后,流Position位于末尾。
因此,流中没有更多内容可供反序列化器读取。

您需要通过设置来倒带流n.Position = 0

于 2011-01-19T15:34:29.997 回答