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. General Programming
  3. C#
  4. Exception of type 'System.Security.SecurityException' occured

Exception of type 'System.Security.SecurityException' occured

Scheduled Pinned Locked Moved C#
helpworkspacesysadminsecuritydebugging
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.
  • P Offline
    P Offline
    Patricker
    wrote on last edited by
    #1

    I'm stuck on this one, really bad. Exact Error Message: An unhandled exception of type 'System.Security.SecurityException' occurred in CheckPageUpdates.exe Additional information: Request failed. If I run my application from my local box it works perfectly. If I run the app off of the Network it fails giving the above error message. Now I know what this issue normally is, it's about not having your Machine->LocalIntranet_Zone setup to allow your program to run with enough rights. So I created a key using sn and added it to the assembly, built my program, then i loaded the key into my Machine->All_Code by adding another group and give it full permissions. This seemed to solve nothing. My program has about 10 lines and it communicates with a webservice which I also wrote. CODE: static void Main() { new CheckPageUpdates(); **}** public CheckPageUpdates() { try { PageModified.PageModifiedService pms = new PageModified.PageModifiedService(); string strAddress = pms.CheckPageUpdated(Environment.GetEnvironmentVariable("username")); if(strAddress != string.Empty) { Process iexplore = new Process(); iexplore.StartInfo.FileName = "iexplore.exe"; iexplore.StartInfo.Arguments = strAddress; iexplore.Start(); } } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } What this does is it hands off the username of the currently logged in user to the webservice which then checks to see if this user has seen a webpage recently enough or if they need to see it again. It then returns a web address, or string.Empty, depending on whether or not they should load a page. When the code fails and I load the debugger it shows me that it failed at the bolded underlined point. Thanks a bunch for at least reading this :) --Peter

    J 1 Reply Last reply
    0
    • P Patricker

      I'm stuck on this one, really bad. Exact Error Message: An unhandled exception of type 'System.Security.SecurityException' occurred in CheckPageUpdates.exe Additional information: Request failed. If I run my application from my local box it works perfectly. If I run the app off of the Network it fails giving the above error message. Now I know what this issue normally is, it's about not having your Machine->LocalIntranet_Zone setup to allow your program to run with enough rights. So I created a key using sn and added it to the assembly, built my program, then i loaded the key into my Machine->All_Code by adding another group and give it full permissions. This seemed to solve nothing. My program has about 10 lines and it communicates with a webservice which I also wrote. CODE: static void Main() { new CheckPageUpdates(); **}** public CheckPageUpdates() { try { PageModified.PageModifiedService pms = new PageModified.PageModifiedService(); string strAddress = pms.CheckPageUpdated(Environment.GetEnvironmentVariable("username")); if(strAddress != string.Empty) { Process iexplore = new Process(); iexplore.StartInfo.FileName = "iexplore.exe"; iexplore.StartInfo.Arguments = strAddress; iexplore.Start(); } } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } What this does is it hands off the username of the currently logged in user to the webservice which then checks to see if this user has seen a webpage recently enough or if they need to see it again. It then returns a web address, or string.Empty, depending on whether or not they should load a page. When the code fails and I load the debugger it shows me that it failed at the bolded underlined point. Thanks a bunch for at least reading this :) --Peter

      J Offline
      J Offline
      James Gupta
      wrote on last edited by
      #2

      In my experiencing, certain operations (especially those relating to files / directories) are not allowed or require extra security permissions to use in .NET. At an educated guess: string strAddress = pms.CheckPageUpdated(Environment.GetEnvironmentVariable("username")); is probably causing it. To suppress it you will need to have your application request additional permissions. This is done through the System.Security namespace, but I am unsure to the specifics of it. Hopefully I have given you enough information to googlise :) James just-code-it.net

      P 1 Reply Last reply
      0
      • J James Gupta

        In my experiencing, certain operations (especially those relating to files / directories) are not allowed or require extra security permissions to use in .NET. At an educated guess: string strAddress = pms.CheckPageUpdated(Environment.GetEnvironmentVariable("username")); is probably causing it. To suppress it you will need to have your application request additional permissions. This is done through the System.Security namespace, but I am unsure to the specifics of it. Hopefully I have given you enough information to googlise :) James just-code-it.net

        P Offline
        P Offline
        Patricker
        wrote on last edited by
        #3

        I tried adding the following to lines in my code file, but I had not change. [assembly:EnvironmentPermissionAttribute(SecurityAction.RequestMinimum, Read="USERNAME")] [assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, All="C:\\Program Files\\Internet Explorer\\iexplore.exe")] I feel like i'm on the right track, but i'm not sure. --Peter

        L 1 Reply Last reply
        0
        • P Patricker

          I tried adding the following to lines in my code file, but I had not change. [assembly:EnvironmentPermissionAttribute(SecurityAction.RequestMinimum, Read="USERNAME")] [assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, All="C:\\Program Files\\Internet Explorer\\iexplore.exe")] I feel like i'm on the right track, but i'm not sure. --Peter

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Patricker wrote:

          SecurityAction.RequestMinimum

          You need to Demand it :)**

          How xacc.ide transforms text to colored words on the screen
          Intel PentuimM (aka Centrino) undervolting

          **

          P 1 Reply Last reply
          0
          • L leppie

            Patricker wrote:

            SecurityAction.RequestMinimum

            You need to Demand it :)**

            How xacc.ide transforms text to colored words on the screen
            Intel PentuimM (aka Centrino) undervolting

            **

            P Offline
            P Offline
            Patricker
            wrote on last edited by
            #5

            If i use demand on either of them then it won't build anymore. I get the following build error: Assembly generation failed -- SecurityAction type invalid on assembly. So I guess I can't demand it... --Peter

            J 1 Reply Last reply
            0
            • P Patricker

              If i use demand on either of them then it won't build anymore. I get the following build error: Assembly generation failed -- SecurityAction type invalid on assembly. So I guess I can't demand it... --Peter

              J Offline
              J Offline
              James Gupta
              wrote on last edited by
              #6

              Sometimes it does not let you at all. Once I wanted to loop through a certain portion of the HD (forgotten why) but no matter how many sec permissions i got, it wouldnt let me do it. Either because of a performance lag on computer or some sensitive files... If your project sounds like it could provoke .NET in any of these areas, try changing it. This is probably not the case, but worth a shot

              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