Bug 32725 - Creating a new System.IO.Compression.ZipArchive fails on mono with SharpCompress.Common.ArchiveException
Summary: Creating a new System.IO.Compression.ZipArchive fails on mono with SharpCompr...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.0.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: João Matos
Depends on:
Reported: 2015-08-03 15:39 UTC by Rasmus Hansen
Modified: 2015-09-05 10:34 UTC (History)
4 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Rasmus Hansen 2015-08-03 15:39:55 UTC
Attempting to create a zip archive results in "SharpCompress.Common.ArchiveException" "Failed to locate the Zip Header".
I made a minimum working issue: http://paste.ubuntu.com/11995302/
This will crash on line 37 if ran under Mono. 

The method when run under normal .Net on windows. 
Tested with Mono nightly build for Mac and Mono 4.0.2 stable for Mac.
Also tested with Mono from github on Linux 8/3/2015. 

Exception doesn't happen if ZipArchiveMode is set to Create instead of Update.
Comment 1 David Schulte 2015-09-04 07:00:42 UTC
A simple fix for this issue may be change ZipArchive's Open() method to test to see if the size of the archive file (or stream) is of length 0 before attempting to read the archive directory or other content.

Due to some other issues with Xamarin's implementation of ZipArchive, I've written a replacement that keeps the same API as ZipArchive, but is based on ZipStorer. My implementation of ZipArchive.Open() does this and works fine.

Is there any update on when this issue might be addressed?
Comment 2 João Matos 2015-09-04 10:24:41 UTC
Pull request up at https://github.com/mono/mono/pull/2033.

Will backport this to 4.2 and 4.0 once its merged.
Comment 3 João Matos 2015-09-04 10:25:11 UTC
Also please also report the other issues you've faced so we can get them fixed.
Comment 4 David Schulte 2015-09-04 10:30:30 UTC
See: https://bugzilla.xamarin.com/show_bug.cgi?id=33553


Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Note You need to log in before you can comment on or make changes to this bug.