Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. FileIOPermission exception with sharpPDF library writing PDF to child dir.

FileIOPermission exception with sharpPDF library writing PDF to child dir.

Scheduled Pinned Locked Moved ASP.NET
workspacecsharpasp-netsysadminwindows-admin
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David Hovey
    wrote on last edited by
    #1

    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

    L T 2 Replies Last reply
    0
    • D David Hovey

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      David Hovey wrote:

      IIS_USRS had modify access already.

      ASP.NET has it's own user-account, called ASP.NET[^]. Does that one have the appropriate rights?

      I are Troll :suss:

      D 1 Reply Last reply
      0
      • L Lost User

        David Hovey wrote:

        IIS_USRS had modify access already.

        ASP.NET has it's own user-account, called ASP.NET[^]. Does that one have the appropriate rights?

        I are Troll :suss:

        D Offline
        D Offline
        David Hovey
        wrote on last edited by
        #3

        Just tried that. Didn't notice that user account, but it doesn't work. Still receive exception.

        L 1 Reply Last reply
        0
        • D David Hovey

          Just tried that. Didn't notice that user account, but it doesn't work. Still receive exception.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          My apologies, simply assumed that the account lacked read/write rights. You could try changing the trust level[^] :)

          I are Troll :suss:

          1 Reply Last reply
          0
          • D David Hovey

            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

            T Offline
            T Offline
            T M Gray
            wrote on last edited by
            #5

            The error says "please contact your system administrator or change the application's trust level in the configuration file" Did you do that?

            D 1 Reply Last reply
            0
            • T T M Gray

              The error says "please contact your system administrator or change the application's trust level in the configuration file" Did you do that?

              D Offline
              D Offline
              David Hovey
              wrote on last edited by
              #6

              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="" />

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups