You call stream.Close()that exactly matches the call Dispose()in the stream.
Just delete this line of code and everything will be fine. Basically, you need to leave it MemoryStreamopen when it returns.
, , , reset . , :
Stream stream = new MemoryStream();
BinaryFormatter bFormatter = new BinaryFormatter();
bFormatter.Serialize(stream, objectToSerialize);
stream.Position = 0;
return stream;
, , Dispose() ( stream.Close()), , , /data back out.