FileIOPermission exception with sharpPDF library writing PDF to child dir.
-
Having problems with free PDF library sharpPDF and allowing it to write PDF file to child directory within ASP.NET application. The PDF is created just fine in my development environment but when deployed to production application (on same computer just separate folder) I receive the below exception. I tried several different things such as: - adding to my web.config file for the application. - verifying NTFS security settings on app directory. Added IIS_WPG with modify privileges. IIS_USRS had modify access already. As well NETWORK SERVICE has modify privileges. Let me know any suggestions.
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. Source Error: Line 97: } Line 98: Line 99: pDoc.createPDF(strOutputFilename); Line 100: Line 101: Response.ContentType = "Application/pdf"; Source File: D:\TerritoryServer\Workspace\WebApp\rtest.aspx.cs Line: 99 Stack Trace: [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() +54 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) +2103 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +138 System.IO.FileStream..ctor(String path, FileMode mode) +91 sharpPDF.pdfDocument.createPDF(String outputFile) +82 TerritoryServer.rtest.Page_Load(Object sender, EventArgs e) in D:\TerritoryServer\Workspace\WebApp\rtest.aspx.cs:99 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25 System.Web.Util.Cal
-
Having problems with free PDF library sharpPDF and allowing it to write PDF file to child directory within ASP.NET application. The PDF is created just fine in my development environment but when deployed to production application (on same computer just separate folder) I receive the below exception. I tried several different things such as: - adding to my web.config file for the application. - verifying NTFS security settings on app directory. Added IIS_WPG with modify privileges. IIS_USRS had modify access already. As well NETWORK SERVICE has modify privileges. Let me know any suggestions.
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. Source Error: Line 97: } Line 98: Line 99: pDoc.createPDF(strOutputFilename); Line 100: Line 101: Response.ContentType = "Application/pdf"; Source File: D:\TerritoryServer\Workspace\WebApp\rtest.aspx.cs Line: 99 Stack Trace: [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() +54 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) +2103 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +138 System.IO.FileStream..ctor(String path, FileMode mode) +91 sharpPDF.pdfDocument.createPDF(String outputFile) +82 TerritoryServer.rtest.Page_Load(Object sender, EventArgs e) in D:\TerritoryServer\Workspace\WebApp\rtest.aspx.cs:99 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25 System.Web.Util.Cal
-
Just tried that. Didn't notice that user account, but it doesn't work. Still receive exception.
-
Just tried that. Didn't notice that user account, but it doesn't work. Still receive exception.
-
Having problems with free PDF library sharpPDF and allowing it to write PDF file to child directory within ASP.NET application. The PDF is created just fine in my development environment but when deployed to production application (on same computer just separate folder) I receive the below exception. I tried several different things such as: - adding to my web.config file for the application. - verifying NTFS security settings on app directory. Added IIS_WPG with modify privileges. IIS_USRS had modify access already. As well NETWORK SERVICE has modify privileges. Let me know any suggestions.
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. Source Error: Line 97: } Line 98: Line 99: pDoc.createPDF(strOutputFilename); Line 100: Line 101: Response.ContentType = "Application/pdf"; Source File: D:\TerritoryServer\Workspace\WebApp\rtest.aspx.cs Line: 99 Stack Trace: [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() +54 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) +2103 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +138 System.IO.FileStream..ctor(String path, FileMode mode) +91 sharpPDF.pdfDocument.createPDF(String outputFile) +82 TerritoryServer.rtest.Page_Load(Object sender, EventArgs e) in D:\TerritoryServer\Workspace\WebApp\rtest.aspx.cs:99 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25 System.Web.Util.Cal
-
The error says "please contact your system administrator or change the application's trust level in the configuration file" Did you do that?
Yes. I tried that with the below excerpt from my web.config file...The articles on this subject were very confusing, so I was hoping someone could shed light on if this is the proper direction for fix. Regarding the below config file excerpt there were some articles that had a blank "originalurl" attribute. I tried that as well, and till same exception. Could it be a trust level associated with the specific library? <system.web> <trust level="Full" originUrl="" />