Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi...
i was try to use a serialization methods for a DataSet

the probleme in the picture:
[img]http://www5.0zz0.com/2012/01/20/09/288177525.jpg[/img]


serialization methods:
C#
 /*************************************************/
        public static void Serialize(DataSet ds, Stream stream)
        {
            BinaryFormatter serializer = new BinaryFormatter();
            serializer.Serialize(stream, ds);
        }

        public static DataSet Deserialize(Stream stream)
        {
            BinaryFormatter serializer = new BinaryFormatter();
            return (DataSet)serializer.Deserialize(stream);
        } 
/***************************************************/


message of probleme: "Fin de flux rencontrée avant la fin de l'analyse."
[edit]English error message: "End of Stream Encountered before parsing was complete"[/edit]
in the instruction: return (DataSet)serializer.Deserialize(stream);


help me...
Posted
Updated 19-Jan-12 22:49pm
v2
Comments
Ganesan Senthilvel 20-Jan-12 4:42am    
error message is not clear.
Michel [mjbohn] 20-Jan-12 4:51am    
English error message: "End of Stream Encountered before parsing was complete"
BobJanova 20-Jan-12 5:03am    
Are you sure the stream is looking at the right place? I.e. if you just go Serialize, Deserialize on the same stream, it will still have the pointer at the end; you need to seek to the beginning (stream.Seek(0, SeekOrigin.Begin)).

In case you're using the same stream for deserialization and serialization, make sure to set your stream back to position 0.

C#
public static DataSet Deserialize(Stream stream)
        {
            BinaryFormatter serializer = new BinaryFormatter();
            stream.Position=0;
            return (DataSet)serializer.Deserialize(stream);
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900