mbraceproject / FsPickler

A fast multi-format message serializer for .NET
http://mbraceproject.github.io/FsPickler/
MIT License
326 stars 52 forks source link

Unable to Deserialize basic examples #12

Closed WonderPanda closed 10 years ago

WonderPanda commented 10 years ago

Sorry if this is a silly question, I am very new to FsPickler, but when trying to run any of the examples from the ReadMe I am getting exception "Unable to read beyond the stream" when attempting to Deserialize. I am using MemoryStream as the underlying stream. Could you provide a more complete example that includes how to properly read from the underlying stream?

Here is the code I am attempting to run from my script file:

let fsp = new FsPickler()

// typed serialization let stream = new System.IO.MemoryStream() fsp.Serialize(stream, Some [1; 2; 3]) let byteArray = stream.ToArray()

fsp.Deserialize(stream)

WonderPanda commented 10 years ago

Found the solution in the Tests project, the stream's position needs to be set back to 0L before it can be Deserialized... My apologies.

eiriktsarpalis commented 10 years ago

Ah, nice. You can always use the Pickle/Unpickle methods if you want to serialize in-memory.

On Thursday, February 20, 2014, WonderPanda notifications@github.com wrote:

Found the solution in the Tests project, the stream's position needs to be set back to 0L before it can be Deserialized... My apologies.

Reply to this email directly or view it on GitHubhttps://github.com/nessos/FsPickler/issues/12#issuecomment-35654734 .

Sent from Gmail Mobile