ZipOutputStream comment NullReferenceException


When using ZipOutputStream and including a comment, ZipOutputStream will throw a NullReferenceException on disposal.
Stack Trace:
at Ionic.Zip.ZipOutput.GenCentralDirectoryFooter(Int64 StartOfCentralDirectory, Int64 EndOfCentralDirectory, Zip64Option zip64, Int32 entryCount, String comment, Encoding encoding)
at Ionic.Zip.ZipOutput.WriteCentralDirectoryStructure(Stream s, ICollection`1 entries, UInt32 numSegments, Zip64Option zip64, String comment, Encoding encoding)
at Ionic.Zip.ZipOutputStream.Dispose(Boolean notCalledFromFinalizer)
Code example:
using (ZipOutputStream zipStream = new ZipOutputStream(OutputStream))
zipStream.CompressionLevel = Ionic.Zlib.CompressionLevel.None;
zipStream.Comment = "Cheeso is the man!";
//If you explicitly set UseUnicodeAsNecessary to false, the error no longer occurs. 
//zipStream.UseUnicodeAsNecessary = false;
// .... Write to stream
} //ex is thrown here
The environment is a Windows XP Professional x86 installation.
I noticed ProvisionalAlternateEncoding is null, and am wondering if that's what's is causing the exception.
Thanks for all your work on this library.
Closed Jun 15, 2011 at 11:54 AM by Cheeso
This is a duplicate of workitem 12634.It was fixed in changeset 79077. First binary with this fix: v1.9.1.6


comius wrote Sep 28, 2010 at 6:05 PM

zout.UseUnicodeAsNecessary = true;

The problem is, that otherwise encoder isn't set (therefore NullReferenceException). The code could be fixed in 5 minutes.

wrote Jun 14, 2011 at 4:55 AM

wrote Jun 15, 2011 at 11:54 AM

wrote Feb 22, 2013 at 1:43 AM

wrote May 16, 2013 at 12:31 PM