Exception of type 'System.Security.SecurityException' occured
-
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 -
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 :) --PeterIn 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
-
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
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 -
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. --PeterPatricker wrote:
SecurityAction.RequestMinimum
You need to
Demand
it :)**How xacc.ide transforms text to colored words on the screen
Intel PentuimM (aka Centrino) undervolting**
-
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**
-
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
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