[Mono-bugs] [Bug 531890] Object serialization fails when using GZipStream

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Aug 30 13:48:12 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=531890

User gonzalo at novell.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=531890#c5





--- Comment #5 from Gonzalo Paniagua Javier <gonzalo at novell.com>  2009-08-30 11:48:07 MDT ---
Also, you should call Close() in GZipStream, both when compressing and
decompressing. There's one unmanaged for each stream that is not freed until
you call Close or the GC disposes the stream.

Given the code that you have, if you want to "reuse" the MemoryStream and still
be able to call Close() on the GZipStream, I would do something like:

       compressStream.Flush ();
       MemoryStream gzinput = new MemoryStream (saveStream.GetBuffer (), 0,
saveStream.Length);
       compressStream.Close ();
       BinaryFormatter reader = new BinaryFormatter();
       var compressedStream = new GZipStream(gzinput,
CompressionMode.Decompress );
.........

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list