在解析完成之前遇到流结束? [英] End of Stream encountered before parsing was completed?
本文介绍了在解析完成之前遇到流结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试反序列化一个流,但我总是收到这个错误在解析完成之前遇到流结束"?
I am trying to deserialize a stream but I always get this error "End of Stream encountered before parsing was completed"?
代码如下:
//Some code here
BinaryFormatter b = new BinaryFormatter();
return (myObject)b.Deserialize(s);//s---> is a Stream object that has been fill up with data some line over here
有人有想法吗?
推荐答案
尝试将流的位置设置为 0,并且不要使用您的对象,而是使用对象类型.
Try to set the position to 0 of your stream and do not use your object but the object type.
BinaryFormatter b = new BinaryFormatter();
s.Position = 0;
return (YourObjectType)b.Deserialize(s);
这篇关于在解析完成之前遇到流结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文