I've integrated the DotNetZip dll into an ASP.net/VB project. But when I try to open a file for reading, I get a security exception:
System.Security.SecurityException: Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
I've looked at a ton of places for help on this error (including several on this site), but nothing seems to work. I get the impression that I need to set my application's trust level. When my application is finished it will need to live on my client's server, where I won't have access to their IIS configuration. Some of the sites I've consulted say to do this in my web.config file. From the MSDN and other places, I've tried variations on this:
<system.web>
<trust level="Full" />
</system.web>
No good. I put my target zip file in the app directory to simplify things, and checked that I have full permissions on that directory. Still no good.
Can anyone tell me how I can set my app's trust level correctly, or if there's something else I need to do? Here's the stack trace in case anyone's interested. And thanks.
[SecurityException: Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&
stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +61
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights,
Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options,
SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +644
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare
share) +66
Ionic.Zip.ZipFile.get_ReadStream() +75
Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf) +46
Ionic.Zip.ZipFile.Read(String fileName, TextWriter statusMessageWriter, Encoding
Ionic.Zip.ZipFile.Read(String fileName) +11
CodeBehind.Page_Load(Object sender, EventArgs e) in W:\research\httpdoc\uploader
\index.aspx.vb:45
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.index_aspx.ProcessRequest(HttpContext context) +37
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +75
If anyone ever reads this and has the same problem, I switched to another package, the SharpZipLib package available here. Seems to be working without security issues.