{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "fixed in changeset 79370 - now there is a clear exception describing the error when you use ZipEntry.Extract with ZipInputStream.  don&#39;t do this&#33; The first binary to contain this fix &#40;the better exception&#41; will be v1.9.1.6.",
    "ClosedDate": "2011-06-17T22:04:26.813-07:00",
    "CommentCount": 0,
    "Custom": null,
    "Description": "The following code throws a NullReference Exception.  Exception details follow code.\n \nDim tZip As Ionic.Zip.ZipInputStream = Nothing\nDim tEntry As Ionic.Zip.ZipEntry = Nothing\nDim tModelStream As Stream = Assembly.GetExecutingAssembly.GetManifestResourceStream(tFeature.Manifest.MediaID & \".Models.zip\")\n \ntZip = New Ionic.Zip.ZipInputStream(tModelStream, False)\nDo\n\ttEntry = tZip.GetNextEntry\n\ttEntry.Extract(sModelPath, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently)\nLoop Until tEntry Is Nothing\n \n \n\"   at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password)    at Ionic.Zip.ZipEntry.Extract(String baseDirectory, ExtractExistingFileAction extractExistingFile)    ..... ..... ..... etc etc",
    "LastUpdatedDate": "2013-05-16T05:31:52.283-07:00",
    "PlannedForRelease": "v1.9.1.8 DotNetZip - Latest Stable",
    "ReleaseVisibleToPublic": true,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2010-03-03T11:41:12.53-08:00",
    "Status": {
      "Name": "Closed",
      "Id": 4
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "ZipInputStream throws NullReferenceException when using ZipEntry.Extract()",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 1,
    "Id": 10355
  },
  "FileAttachments": [],
  "Comments": [
    {
      "Message": "I need the entire exception in order to figure this out.  Not just the exception location.  The actual exception, plus the complete stacktrace.  Also, have you verified that tModelStream is not Nothing?  \r\n\r\n\r\n",
      "PostedDate": "2010-03-05T04:24:21.877-08:00",
      "Id": -2147483648
    },
    {
      "Message": "I believe I know what the issue is, as I've run into something similar with similar code. In my case, however, I was extracting to a stream, not a file path.\r\n\r\nMessage: Object reference not set to an instance of an object. (NullReferenceException)\r\nStack Trace:    at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password) in C:\\DotNetZip\\v1.9.1.5\\DotNetZip\\Zip Partial DLL\\ZipEntry.Extract.cs:line 602\r\n   at Ionic.Zip.ZipEntry.Extract(Stream stream) in C:\\DotNetZip\\v1.9.1.5\\DotNetZip\\Zip Partial DLL\\ZipEntry.Extract.cs:line 112\r\n   at StarkBros.Biz.Finance.Paymentech.NetConnectBatchTransport.GetResponses() in C:\\StarkBros\\src\\ursa\\BusinessLayer\\Finance\\Paymentech\\Transport.vb:line 323\r\n\r\nNote that InternalExtract calls _container.ZipFile.Reset(), which is presumably an issue because the container is a ZipInputStream, not a ZipFile. Based on that, I wouldn't expect ZipEntry.InternalExtract to ever work for a ZipInputStream.\r\n\r\nI switched to using the Read(Byte(), Integer, Integer) method on the ZipInputStream itself, which works fine for my case.",
      "PostedDate": "2010-04-22T08:15:02.45-07:00",
      "Id": -2147483648
    },
    {
      "Message": "// class ZipInputStream\r\n  internal string _password;\r\n\r\n// class ZipContainer\r\npublic string Password\r\n{\r\n  get\r\n  {\r\n    if (_zis != null) return _zis._password;\r\n    if (_zos != null) return _zos._password;\r\n    return _zf._Password;\r\n    //if (_zf != null) return _zf._Password;\r\n    //return _zos._password;\r\n  }\r\n}\r\n",
      "PostedDate": "2010-05-24T07:36:07.097-07:00",
      "Id": -2147483648
    },
    {
      "Message": "the code i just posted also fix same Exception in OpenReader()",
      "PostedDate": "2010-05-24T08:27:41.7-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Thanks, nanalich, I've put those changes in.  ",
      "PostedDate": "2010-06-02T15:48:47.333-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2010-06-02T15:49:10.577-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2011-06-17T21:43:31.73-07:00",
      "Id": -2147483648
    },
    {
      "Message": "I am reversing myself on this.  The ZipInputStream model and metaphor calls for just READing the stream itself, there should be no need to call ZipEntry.Extract().  See the \"workaround\" described by saracoth - this is actually the documented, accepted, correct usage model for ZipInputStream.   Check the documentation on that class for more details and examples.  \r\n\r\nI don't know why I thought it was a good idea to allow this, previously. I was confused.\r\n\r\nIf you want to call ZipEntry.Extract(), you should use a ZipFile() class, which is a different metaphor.  I've made a code change to throw a clear exception if you try to call ZipEntry.Extract on an entry you received from a ZipInputStream.  \r\n",
      "PostedDate": "2011-06-17T22:03:19.253-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2011-06-17T22:04:26.813-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Cheeso, I got the same problem as saracoth.\r\n\r\nI do the following:\r\n\r\nZipEntry MyEntry = MyZipInputStream.GetNextEntry();\r\nwhile (MyEntry != null)\r\n{\r\n    using (MemoryStream MyExtractedFile = new MemoryStream())\r\n    {\r\n        MyEntry.Extract(MyExtractedFile);\r\n    }\r\n    MyEntry = MyZipInputStream.GetNextEntry();\r\n}\r\n\r\n\r\nThe stacktrace I then have, is the same as saracoth. So MyEntry.Extract(MyExtractedFile) will call InternalExtract(null, MyExtractedFile, Null).\r\n\r\nthe function works until:\r\n\r\n        private void InternalExtract(string baseDir, Stream outstream, string password)\r\n        {\r\n            // workitem 7958\r\n            if (_container == null)\r\n                throw new BadStateException(\"This ZipEntry is an orphan.\");\r\n\r\n            _container.ZipFile.Reset();\r\n\r\n_container.Zipfile.Reset();\r\n\r\n_container is not null, but Zipfile is, so we receive a nullreference exception.",
      "PostedDate": "2011-08-18T01:49:24.513-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Ok this was really my fault. I used wrong syntax. Ofcourse....\r\n\r\nI used a ZipInputReader, but actually I needed a plain ZipFile as in:\r\n\r\nusing(ZipFile myZipFile = new ZipFile(pathtofile))\r\n\r\nForeach (ZipEntry MyEntry in myZipFile.Entries)\r\n{\r\nusing (MemoryStream MyExtractedFile = new MemoryStream())\r\n{\r\nMyEntry.Extract(MyExtractedFile);\r\n}\r\n}",
      "PostedDate": "2011-08-18T02:02:52.293-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-02-21T18:43:38.583-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-05-16T05:31:52.283-07:00",
      "Id": -2147483648
    }
  ]
}