[
  {
    "Id": "619057",
    "ThreadId": "259182",
    "Html": "\r\n<p>Hi Experts,</p>\r\n<p>i'm sorry maybe this topic has been posted for many times, but i just couldn't find any solution for this case.</p>\r\n<p>i'm building a webservice that need to provide a list of images for mobile application to download, but for some reasons i need to zip all images into a zip file and send it to mobile application.</p>\r\n<p>Well after googling i found DotNetZip which is very powerful to handle zip code in C#.</p>\r\n<p>So after i downloaded and test it on my project, i got the exception as below :</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre>{System.Security.SecurityException: Request <span style=\"color:blue\">for</span> the permission of type <span style=\"color:#a31515\">'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'</span> failed.\r\n   at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet)\r\n   at System.Security.CodeAccessPermission.Demand()\r\n   at System.IO.File.GetLastWriteTimeUtc(String path)\r\n   at Ionic.Zip.ZipEntry.Create(String nameInArchive, ZipEntrySource source, Object arg1, Object arg2)\r\n   at Ionic.Zip.ZipEntry.CreateFromFile(String filename, String nameInArchive)\r\n   at Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive)\r\n   at Ionic.Zip.ZipFile.AddFile(String fileName)\r\n   at GEOTag.Service.TagService.GetGEOTagsRP(String userName, String longitude, String latitude, String range, String courseId) <span style=\"color:blue\">in</span> D:\\dev\\GEOTag\\trunk\\GEOTag.Service\\TagService.svc.cs:line 471\r\nThe action that failed was:\r\nDemand\r\nThe type of the first permission that failed was:\r\nSystem.Security.Permissions.FileIOPermission\r\nThe first permission that failed was:\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nRead=<span style=\"color:#a31515\">&quot;D:\\dev\\GEOTag\\trunk\\GEOTag.Service\\Images\\9cd11de8-d2ad-4fc5-8fe6-02b9cc9af540.jpg&quot;</span>/&gt;\r\n\r\nThe demand was <span style=\"color:blue\">for</span>:\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nRead=<span style=\"color:#a31515\">&quot;D:\\dev\\GEOTag\\trunk\\GEOTag.Service\\Images\\9cd11de8-d2ad-4fc5-8fe6-02b9cc9af540.jpg&quot;</span>/&gt;\r\n\r\nThe granted <span style=\"color:blue\">set</span> of the failing assembly was:\r\n&lt;PermissionSet <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.PermissionSet&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>&gt;\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.FileDialogPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nAccess=<span style=\"color:#a31515\">&quot;Open&quot;</span>/&gt;\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nAllowed=<span style=\"color:#a31515\">&quot;ApplicationIsolationByUser&quot;</span>\r\nUserQuota=<span style=\"color:#a31515\">&quot;512000&quot;</span>/&gt;\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nFlags=<span style=\"color:#a31515\">&quot;Execution&quot;</span>/&gt;\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nWindow=<span style=\"color:#a31515\">&quot;SafeTopLevelWindows&quot;</span>\r\nClipboard=<span style=\"color:#a31515\">&quot;OwnClipboard&quot;</span>/&gt;\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nPublicKeyBlob=<span style=\"color:#a31515\">&quot;0024000004800000940000000602000000240000525341310004000001000100D368A9B3F717497EB8BEC03301F7D91BC80FA684DE99D25B34A733959C9874F4A7F89037176E8D30D3DE28403CE49D306E98C89701C145879A302AD5D2D5A8879C62FEB7B9DCFB4BFFCB012BCADF367D7B42D0D249351B9B9B1EC01277739AF165756C35120B9F982CDEE8A03BD09451E8DE927B83442EB8A95F0A5DBCA19AB1&quot;</span>\r\nName=<span style=\"color:#a31515\">&quot;Ionic.Zip&quot;</span>\r\nAssemblyVersion=<span style=\"color:#a31515\">&quot;1.9.1.5&quot;</span>/&gt;\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nUrl=<span style=\"color:#a31515\">&quot;file:///D:/dev/GEOTag/trunk/GEOTag.Service/bin/Ionic.Zip.DLL&quot;</span>/&gt;\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nZone=<span style=\"color:#a31515\">&quot;Internet&quot;</span>/&gt;\r\n&lt;IPermission <span style=\"color:blue\">class</span>=<span style=\"color:#a31515\">&quot;System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;</span>\r\nversion=<span style=\"color:#a31515\">&quot;1&quot;</span>\r\nLevel=<span style=\"color:#a31515\">&quot;SafePrinting&quot;</span>/&gt;\r\n&lt;/PermissionSet&gt;\r\n\r\nThe assembly or AppDomain that failed was:\r\nIonic.Zip, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c\r\nThe method that caused the failure was:\r\nIonic.Zip.ZipEntry Create(System.String, Ionic.Zip.ZipEntrySource, System.Object, System.Object)\r\nThe Zone of the assembly that failed was:\r\nInternet\r\nThe Url of the assembly that failed was:\r\nfile:<span style=\"color:gray\">///</span><span style=\"color:green\">D:/dev/GEOTag/trunk/GEOTag.Service/bin/Ionic.Zip.DLL}</span>\r\n</pre>\r\n</div>\r\n<p></p>\r\n<p>&nbsp;</p>\r\n<p>It got exception when i added a file into dotnetzip object&nbsp;</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><span style=\"color:blue\">string</span> zipFile = <span style=\"color:#a31515\">&quot;C:\\\\testing\\\\images.zip&quot;</span>;\r\n<span style=\"color:blue\">if</span> (File.Exists(zipFile))\r\n{\r\n    File.Delete(zipFile);\r\n}\r\n\r\n<span style=\"color:blue\">using</span> (ZipFile zip = <span style=\"color:blue\">new</span> ZipFile())\r\n{\r\n<span style=\"color:#ff0000\">    zip.AddFile(imageList[0].ToString()); &lt;------- exception at this step</span>\r\n    zip.Save(zipFile);\r\n}\r\n</pre>\r\n</div>\r\n<p></p>\r\n<p>i've googled many times but got no solution,</p>\r\n<p>what should i do to make it works?</p>\r\n<p>do i need to add module or configure the PowerShell ?</p>\r\n<p>or do i need to make some configuration on the Web.Config ?</p>\r\n<p>or do i need to add authentication on IIS for IO.Permission ?</p>\r\n<p>i'm really confuse please give me some guide....</p>\r\n<p>&nbsp;</p>\r\n<p>Thx</p>\r\n<p>Stone</p>\r\n",
    "PostedDate": "2011-05-26T20:31:59.447-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "619498",
    "ThreadId": "259182",
    "Html": "<p>It looks like your IIS user lacks Read permission on the indicated JPG files.</p>\r\n<p>To avoid the permissions error, You will need to grant permissions to the appropriate IIS user or group.</p>",
    "PostedDate": "2011-05-27T11:47:15.053-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "620102",
    "ThreadId": "259182",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>Thx for your reply,</p>\r\n<p>I've full permission on JPG files as well,</p>\r\n<p>i can guarantee this thing, because before zip images file, my webservice can create images (from database) into \"images folder\" as well</p>\r\n<p>so after the app created all images, i've to zip all images into zip file.</p>\r\n<p>and when i addin image into DotNetZip object it prompted this error...</p>\r\n<p>Do i need to configure other things??</p>\r\n<p>&nbsp;</p>\r\n<p>Thx</p>\r\n<p>Stone</p>",
    "PostedDate": "2011-05-29T19:58:09.93-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "620978",
    "ThreadId": "259182",
    "Html": "<p>The exception stack trace you showed is very clear:&nbsp; it is a permission denied error when trying to get the lastModified time of a file.&nbsp;</p>\r\n<p>Therefore your guarantee seems unfounded. That you can *create* new files is not a guarantee that you can read all existing files.</p>\r\n<p>I would double-check your assumptions. The stack trace looks pretty unequivocal to me.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-05-31T12:21:09.637-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "621134",
    "ThreadId": "259182",
    "Html": "<p>The strange things is i try this on my webserver, it works well</p>\r\n<p>but when i try on my local machine, it got exception.</p>\r\n<p>fyi: my webserver's application data all located on inetpub\\wwwroot\\...</p>\r\n<p>&nbsp; &nbsp; &nbsp;but my local machine is located on my D:\\ and i just regis it on my IIS.</p>\r\n<p>so i wonder if the problem lies on my IIS, but i already give the full permission to \"everyone\" on IIS,</p>\r\n<p>thats why i asked everyone if there're any other configuration that i have to set, or its related with Windows PowerShell or any others...</p>\r\n<p>&nbsp;</p>\r\n<p>Thx :)</p>\r\n<p>Stone</p>",
    "PostedDate": "2011-05-31T19:30:30.433-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "621956",
    "ThreadId": "259182",
    "Html": "<p>Powershell?&nbsp;</p>\r\n<p>I thought your code was running in IIS?</p>\r\n<p>Powershell does have some special security constraints when running scripts from networked drives. But I don't see a powershell error in the stack trace.</p>\r\n<p>I'm afraid I don't understand the problem at all now.&nbsp; It's not clear to me what you are doing or what problem you are having or how powershell is at all related.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-06-02T06:30:27.697-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "622302",
    "ThreadId": "259182",
    "Html": "<p>Well i'm so sorry to caused your confusion, the reason why i asked whether its related with powershell is because</p>\r\n<p>when i was googling got many people on forums suggest to check the Powershell configuration, thats why i'm asking whether its related from my case or not.</p>\r\n<p>&nbsp;</p>\r\n<p>OK i'll try to explain more detail...</p>\r\n<p>I'm building a web service which is used for a mobile application to retrieve a list of images from my server database.</p>\r\n<p>for this case, i'm using VS 2008 to build the project and SQL Server 2008 as the DBMS.</p>\r\n<p>I'm registering my web service on my local IIS for local testing and when the testing is done, i'll deploy it to my web server.</p>\r\n<p>Basically i'm just retrieve all my images from database and convert it from binary into JPG files and save it on \"Images\" root directory.</p>\r\n<p>So the mobile application will just retrieve all images by download based on web URL per image (e.x. www.xxxx.com/Images/test.jpg).</p>\r\n<p>But the mobile often got corrupted image, so we decided to zip all images and mobile only need to retrieve a single file instead of a list image files.</p>\r\n<p>Now the case is i'm encountered the error when i'm doing testing on my local testing, but on my web server it works fine.</p>\r\n<p>&nbsp;</p>\r\n<p>Thats why i'm quite confuse what is the caused of this error, all code, web.config, configuration of security permission is same from my local and webserver.</p>",
    "PostedDate": "2011-06-02T19:54:21.03-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]