Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"?

Here is the code:

        //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 

Any one have ideas?

like image 552
Mister Dev Avatar asked Nov 20 '08 19:11

Mister Dev


1 Answers

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); 
like image 95
Patrick Desjardins Avatar answered Oct 08 '22 21:10

Patrick Desjardins