[
  {
    "Id": "211129",
    "ThreadId": "62205",
    "Html": "<p>\r\n<div><span style=\"color:#0000ff\">Hi, I am attempting to execute the following code using the DotNetZip Library versions v1.7 and v1.8:</span></div>\r\n</p>\r\n<p>\r\n<div><span style=\"color:#0000ff\">\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">Protected</span> <span style=\"color:Blue\">Sub</span> CreateAlbumZipFile(<span style=\"color:Blue\">ByVal</span> Context <span style=\"color:Blue\">As</span> HttpContext)\r\n\r\n        <span style=\"color:Blue\">Try</span>\r\n\r\n            Context.Response.AddHeader(<span style=\"color:#A31515\">&quot;Content-Disposition&quot;</span>, <span style=\"color:#A31515\">&quot;attachment; filename=test.zip&quot;</span>)\r\n            \r\n            <span style=\"color:Green\">' Create the Album Zip File</span>\r\n            <span style=\"color:Blue\">Dim</span> AlbumZipFile <span style=\"color:Blue\">As</span> ZipFile = <span style=\"color:Blue\">New</span> ZipFile()\r\n\r\n            <span style=\"color:Green\">' Specify a temporary folder when creating the ZipFile if needed (must be a location that exists and is writable by the website)</span>\r\n            AlbumZipFile.TempFileFolder = HttpContext.Current.Server.MapPath(TempLocation)\r\n\r\n            <span style=\"color:Green\">' Add single item to zip file</span>\r\n            AlbumZipFile.AddFile(HttpContext.Current.Server.MapPath(AlbumLocation &amp; <span style=\"color:#A31515\">&quot;ContentID_1962.Orig.jpg&quot;</span>), <span style=\"color:#A31515\">&quot;&quot;</span>)\r\n\r\n            <span style=\"color:Green\">' Saves the Zip File (use the Response.OutputStream)</span>\r\n            AlbumZipFile.Save(Context.Response.OutputStream)\r\n                \r\n            Context.Response.<span style=\"color:Blue\">End</span>()\r\n\r\n            AlbumZipFile.Dispose()\r\n\r\n        <span style=\"color:Blue\">Catch</span> ex <span style=\"color:Blue\">As</span> Exception\r\n            \r\n        <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Try</span>\r\n\r\n    <span style=\"color:Blue\">End Sub</span>\r\n</pre>\r\n</div>\r\n<p>To simulate my shared hosting environment I have set my trust level to &quot;Medium&quot; in the Web.config.</p>\r\n<p><span style=\"color:#0000ff\">If I use the DotNetZip Library <strong>v1.7</strong> an exception is raised on the <span style=\"color:#000000\">Context.Response.End() </span>call:</span></p>\r\n</span></div>\r\n</p>\r\n<p><span style=\"color:#0000ff\">\r\n<p>&nbsp;&nbsp;&nbsp; <span style=\"color:#000000\">&quot;System.Threading.ThreadAbortException&quot;</span></p>\r\n<p><span style=\"color:#0000ff\">But, the ZipFile is still successfully sent to the user.</span></p>\r\n<p><span style=\"color:#0000ff\">If I use the DotNetZip Library <strong>v1.8</strong> an exception is raised on the <span style=\"color:#000000\">AlbumZipFile.Save(Context.Response.OutputStream)</span> call:</span></p>\r\n<p><span style=\"color:#0000ff\">&nbsp;&nbsp;&nbsp; <span style=\"color:#000000\">&quot;Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.&quot;</span></span></p>\r\n<p><span style=\"color:#0000ff\">The only change I made was to&nbsp;remove version v1.7.2.26 and replace it with v1.8.4.5 of Ionic.Zip.dll in my WebSite's Bin folder.&nbsp; I then restarted the web app and retested.</span></p>\r\n<p><span style=\"color:#0000ff\">Other notes:</span></p>\r\n<ul>\r\n<li><span style=\"color:#0000ff\">I am creating the zip file in memory and streaming it to the Response.OutputStream when having problems</span></li>\r\n<li><span style=\"color:#0000ff\">v1.6 works fine (requires some minor code changes) but does not provide the FileName rename feature I would like to use for better performance when I have to create a ZipFile containing files with different names than the originals</span></li>\r\n<li><span style=\"color:#0000ff\">v1.7 works fine if you create the zip first and save it to a file and later send that file via a Response.TransmitFile(pathname)</span></li>\r\n<li><span style=\"color:#0000ff\">Using VS.NET 2005</span></li>\r\n</ul>\r\n<p><span style=\"color:#0000ff\">So, I am wondering if we truely have &quot;Medium Trust&quot; support with v1.7 and v1.8 like we appear to have with v1.6.</span></p>\r\n<p><span style=\"color:#0000ff\">Thanks for your help!</span></p>\r\n</span></p>",
    "PostedDate": "2009-07-11T14:49:01.32-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211135",
    "ThreadId": "62205",
    "Html": "<p>I think you can avoid the thread abort Exception if you don't call Response.End().&nbsp;</p>\r\n<p>You can call Context.<span>ApplicationInstance</span><span>.</span><span>CompleteRequest</span><span>() instead.&nbsp; See this KB Article for info:&nbsp; <a href=\"http://support.microsoft.com/kb/312629\">http://support.microsoft.com/kb/312629</a>&nbsp;</span></p>\r\n<p><span>As for v1.8 - ... I don't know why it would fail like that.&nbsp; It is marked APTC, which means it should work, and of course I test that case - saving a zip file directly to the ASP.NET Response output stream under medium trust - regularly.&nbsp; </span></p>\r\n<p><span>Are you running your website from a network share or a mapped drive?</span></p>\r\n<p><span>Do you have a complete stack trace of the SecurityPermission error?&nbsp; That would help me track it down very quickly. </span></p>\r\n<p><span>Thanks</span></p>\r\n<p><span>&nbsp;</span></p>",
    "PostedDate": "2009-07-11T15:50:43.093-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211137",
    "ThreadId": "62205",
    "Html": "<p>Hi,</p>\r\n<p>Thanks for the quick response and thanks for the information about <strong>CompleteRequest()</strong>.&nbsp; Good to know.</p>\r\n<p>Here is the complete stack trace:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>   at Ionic.Zip.SharedUtilities.ReadWithRetry(Stream s, <span style=\"color:Blue\">Byte</span>[] buffer, Int32 offset, Int32 <span style=\"color:Blue\">count</span>, <span style=\"color:Blue\">String</span> FileName)\r\n   at Ionic.Zip.ZipEntry._WriteFileData(Stream s)\r\n   at Ionic.Zip.ZipEntry._EmitOne(Stream outstream)\r\n   at Ionic.Zip.ZipEntry.Write(Stream s)\r\n   at Ionic.Zip.ZipFile.Save()\r\n   at Ionic.Zip.ZipFile.Save(Stream outputStream)\r\n   at VirtualZipFileFetch.CreateAlbumZipFile(HttpContext Context)\r\n</pre>\r\n</div>\r\n<p>&nbsp;Let me know if you need anything else!</p>",
    "PostedDate": "2009-07-11T16:31:19.53-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211156",
    "ThreadId": "62205",
    "Html": "<p>Ah, yes, that ReadWithRetry method is new for v1.8.&nbsp;&nbsp;&nbsp;&nbsp; I will have to look at it further.</p>",
    "PostedDate": "2009-07-11T21:21:19.02-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211184",
    "ThreadId": "62205",
    "Html": "<table border=0 width=600>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<p>The problem you're having with v1.8 - Is it easily reproducible?&nbsp; Does it happen <em>every time</em>, with any set of files you try to zip?&nbsp;&nbsp; Or are there particular files that cause the problem?</p>\r\n<p>Can you run with the debug library (and the Ionic.Zip.PDB in the bin directory) so that your stacktrace includes line numbers?</p>\r\n<p>It looks like what's happening is, your save is getting an exception while reading one of the files during compression.&nbsp; That exception is caught, and in the handler, the code attempts to get the HRESULT that is embedded in the exception. This requires unmanaged code, which throws the SecurityPermission error. This is a guess on my part.</p>\r\n<p>If you can repro the problem readily, and don't mind working through this with me, I could provide an updated v1.8 binary for you to test, to verify that I've fixed the problem.</p>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>",
    "PostedDate": "2009-07-12T06:28:22.807-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211187",
    "ThreadId": "62205",
    "Html": "<table border=0 width=600>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<p>ps: Just a tip: in either v1.7 or v1.8, when saving to a stream, like Response.OutputStream, you don't need to set TempFileFolder.&nbsp;There is no temp file produced when saving to a stream.&nbsp; Also in v1.8, you shouldn't need to set TempFileFolder ever.&nbsp; As I said, it isn't used when saving to a stream, and when saving to a file, DotNetZip has been changed to create the temp file in the same folder as the final file.&nbsp; So in v1.8, the TempFileFolder property becomes unnecessary.</p>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>",
    "PostedDate": "2009-07-12T06:52:44.82-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211192",
    "ThreadId": "62205",
    "Html": "<p>Hi,</p>\r\n<p>Yes, the problem is&nbsp;consistantly reproducible.&nbsp; I have switched the testcase to different jpgs and they all reproduce the problem.&nbsp; I remember you saying that the TempFileFolder was not needed from another post but I just wanted to set it since I had been using it in v1.6 and earlier and wanted to make sure that the problem was not related in some way.&nbsp; I have updated the testcase to the following and I am still able to reproduce the problem with the same stack:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>        <span style=\"color:Blue\">Try</span>\r\n\r\n            Context.Response.AddHeader(<span style=\"color:#A31515\">&quot;Content-Disposition&quot;</span>, <span style=\"color:#A31515\">&quot;attachment; filename=test.zip&quot;</span>)\r\n    \r\n            <span style=\"color:Green\">' Create the Album Zip File</span>\r\n            <span style=\"color:Blue\">Dim</span> AlbumZipFile <span style=\"color:Blue\">As</span> ZipFile = <span style=\"color:Blue\">New</span> ZipFile()\r\n\r\n            <span style=\"color:Green\">' Specify the temporary folder when creating the AlbumZipFile (must be a location that exists and is writable by the website)</span>\r\n            <span style=\"color:Green\">'AlbumZipFile.TempFileFolder = HttpContext.Current.Server.MapPath(TempLocation)</span>\r\n\r\n            <span style=\"color:Green\">' Add single item to zip file</span>\r\n            AlbumZipFile.AddFile(HttpContext.Current.Server.MapPath(AlbumLocation &amp; <span style=\"color:#A31515\">&quot;ContentID_162.Orig.jpg&quot;</span>), <span style=\"color:#A31515\">&quot;&quot;</span>)\r\n\r\n            <span style=\"color:Green\">' Saves the Album Zip File (writes the Zip File to the Response.OutputStream)</span>\r\n            AlbumZipFile.Save(Context.Response.OutputStream)\r\n\r\n            AlbumZipFile.Dispose()\r\n        \r\n            Context.Response.<span style=\"color:Blue\">End</span>()\r\n\r\n        <span style=\"color:Blue\">Catch</span> ex <span style=\"color:Blue\">As</span> Exception\r\n    \r\n        <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Try</span>\r\n</pre>\r\n</div>\r\n<p>The stack trace is still</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><div style=\"color:Black;background-color:White\"><pre><span style=\"color:#808080\"><div style=\"color:Black;background-color:White\"><pre><span style=\"color:#808080\">   at Ionic.Zip.SharedUtilities.ReadWithRetry(Stream s, Byte[] buffer, Int32 offset, Int32 count, String FileName)\r\n   at Ionic.Zip.ZipEntry._WriteFileData(Stream s)\r\n   at Ionic.Zip.ZipEntry._EmitOne(Stream outstream)\r\n   at Ionic.Zip.ZipEntry.Write(Stream s)\r\n   at Ionic.Zip.ZipFile.Save()\r\n   at Ionic.Zip.ZipFile.Save(Stream outputStream)\r\n   at VirtualZipFileFetch.CreateAlbumZipFile(HttpContext Context)</span></pre>\r\n</div>\r\n</span></pre>\r\n</div>\r\n</pre>\r\n</div>\r\n<p>But, I dont see any line numbers associated with the stack trace.&nbsp; I have placed <strong>Ionic.Zip.dll </strong>and <strong>Ioniz.Zip.pdb</strong> from <strong>DotNetZipLib-DevKit-v1.8\\DotNetZip-v1.8\\Debug</strong> into my WebSite's Bin folder.&nbsp; I left the <strong>Ionic.Zip.XML</strong> file alone.&nbsp; Is that needed as well?</p>\r\n<p>It did ask me to point to the source code file <strong>DotNetZip-src-v1.8.4.5\\DotNetZip\\Zip Partial DLL\\ZipFile.cs</strong> if I put a break point on the call to <strong>AlbumZipFile.Save(Context.Response.OutputStream)</strong>.&nbsp; It steps into the code in ZipFile.cs at line <strong>3928</strong>:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">public</span> void Save(Stream outputStream)\r\n</pre>\r\n</div>\r\n<p>Following the stack of calls I then stepped through the code until it came to the call to <strong>ReadWithRetry</strong>.&nbsp; I got to line <strong>4184</strong> of <strong>ZipEntry.cs</strong> but never saw the debugger step into the call to <strong>ReadWithRetry</strong> here:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><strong>4178</strong>      <span style=\"color:Blue\">while</span> ((n = SharedUtilities.ReadWithRetry(input1, buffer, 0, buffer.Length, FileName)) != 0)\r\n                {\r\n                    output2.Write(buffer, 0, n);\r\n                    OnWriteBlock(input1.TotalBytesSlurped, fileLength);\r\n                    <span style=\"color:Blue\">if</span> (_ioOperationCanceled)\r\n                        <span style=\"color:Blue\">break</span>;\r\n<strong>4184 </strong>     }</pre>\r\n</div>\r\n<p>The call stack window looked like this at this point:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>&gt;\tIonic.Zip.DLL!Ionic.Zip.ZipEntry._WriteFileData(System.IO.Stream s = {Ionic.Zip.CountingStream}) Line 4184 + 0x1 bytes\tC#\r\n \tIonic.Zip.DLL!Ionic.Zip.ZipEntry._EmitOne(System.IO.Stream outstream = {Ionic.Zip.CountingStream}) Line 4531 + 0xb bytes\tC#\r\n \tIonic.Zip.DLL!Ionic.Zip.ZipEntry.Write(System.IO.Stream s = {Ionic.Zip.CountingStream}) Line 4495 + 0xb bytes\tC#\r\n \tIonic.Zip.DLL!Ionic.Zip.ZipFile.Save() Line 3678 + 0x2a bytes\tC#\r\n \tIonic.Zip.DLL!Ionic.Zip.ZipFile.Save(System.IO.Stream outputStream = {System.Web.HttpResponseStream}) Line 3940 + 0x8 bytes\tC#\r\n \tApp_Web_870ybjh0.dll!VirtualZipFileFetch.CreateAlbumZipFile(System.Web.HttpContext Context = {System.Web.HttpContext}) Line 327 + 0x2d bytes\tBasic\r\n \tApp_Web_870ybjh0.dll!VirtualZipFileFetch.ProcessRequest(System.Web.HttpContext Context = {System.Web.HttpContext}) Line 33 + 0xe bytes\tBasic\r\n\r\n</pre>\r\n</div>\r\n<p>It then jumps into the <strong>finally</strong> block on <strong>4203</strong> as it appears the exception is raised at this point.&nbsp; I am not sure why I cannot step into the call <strong>ReadWithRetry</strong> at this point.&nbsp; If you have any&nbsp;ideas on what I may be doing wrong or how to get the call stack you are looking for, please let me know.</p>\r\n<p>Thanks.</p>",
    "PostedDate": "2009-07-12T07:42:20.077-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211204",
    "ThreadId": "62205",
    "Html": "<table border=0 width=800>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<p>yes, I think I have some insight into what's happening. and maybe how to avoid the problem.&nbsp; I think you might be good-to-go with v1.7, assuming you are no longer calling Response.End().&nbsp; But I would like you to keep trying v1.8 if you are willing.</p>\r\n<p>In a while, I'll put up a temporary assembly and ask you to try it.&nbsp;</p>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>",
    "PostedDate": "2009-07-12T10:17:08.1-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211205",
    "ThreadId": "62205",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8009\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-07-12T10:20:21.02-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211419",
    "ThreadId": "62205",
    "Html": "<p>Unfortunately the same problem occurred with the test build.&nbsp; I&nbsp;think the pdb file no longer matches the source I am using so&nbsp;stepping through the source did not seem to match the correct line numbers.</p>",
    "PostedDate": "2009-07-13T11:36:47.87-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211507",
    "ThreadId": "62205",
    "Html": "<p>Thanks for trying it.&nbsp; Yeah, the source has changed.</p>\r\n<p>It would be easier if I could reproduce the problem here.&nbsp; I don't know why I cannot.</p>\r\n<p>I have to think about this some more, to figure out a good way to test and debug it.</p>",
    "PostedDate": "2009-07-13T15:02:57.837-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211564",
    "ThreadId": "62205",
    "Html": "<p>If you want, I think I could put together a VS.NET 2005 Web App that does nothing more than reproduce this problem with v1.8 and would run under the ASP.NET Development Server that comes with VS.NET.&nbsp; Let me know if you think that would help.</p>",
    "PostedDate": "2009-07-13T20:56:51.203-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "211697",
    "ThreadId": "62205",
    "Html": "<table border=0 width=640>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<p>Ah, thank you for the offer.&nbsp; I have exactly that right here, trust=medium, and so on, but it is not generating the problem.</p>\r\n<p>I don't think it is a matter of the ASP.NET code. It is more likely something to do with the server configuration, the directory permissions, the security groups, and I'm not looking forward to getting all that just right. Too many different combinations to try. I have to think about it some more.</p>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>",
    "PostedDate": "2009-07-14T05:45:29.157-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "213889",
    "ThreadId": "62205",
    "Html": "<p>I've reproduced the problem you reported and I believe I've fixed it.&nbsp;</p>\r\n<p>I'd like you to download v1.8.4.8 and verify that it's fixed for you.&nbsp; It's available now.</p>",
    "PostedDate": "2009-07-20T10:23:15.047-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "214052",
    "ThreadId": "62205",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>I just tested&nbsp;v1.8.4.8&nbsp;and it appears to be working great!&nbsp; Not sure what you had to change but whatever it was,&nbsp;it has made the difference.&nbsp; I am going to perform some more thorough testing but it looks like its fixed.</p>\r\n<p>Thanks!</p>",
    "PostedDate": "2009-07-20T16:17:55.76-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "214122",
    "ThreadId": "62205",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>I performed some pretty thorough testing regarding my web applications functionality based on zip files and it&nbsp;passed with flying colors!</p>\r\n<p>Wanted to let you know how much I appreciate the help and resolution of this issue.&nbsp; Not only is this a great library that is easy to use with a rich set of functionality that&nbsp;gives my application another dimension via the DotNetZip Library,&nbsp;but most importantly, the support you provide is top notch!&nbsp; Simply exceptional!</p>\r\n<p>As a small token of my appreciation I will be making a donation.</p>\r\n<p>Thanks again,</p>\r\n<p>-DBall</p>",
    "PostedDate": "2009-07-20T21:30:25.32-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "214267",
    "ThreadId": "62205",
    "Html": "<p>Super, glad to hear it's working,</p>\r\n<p>and thanks for the donation!&nbsp; Very generous of you.&nbsp;&nbsp; It's much appreciated.</p>",
    "PostedDate": "2009-07-21T05:27:59.793-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]