Security.PermissionSet via Console and Windows Forms
From: Duke (d_dejanews_at_yahoo.co.uk)
Date: 05/26/04
- Next message: Toni: "Security error when loading plugin from shared folder."
- Previous message: Michel Gallant: "Re: Generate Public/Private Keys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 26 May 2004 01:15:47 -0700
The June issue of MSDN magazine has an article on Unexpected Errors in
Managed Applications. It gives an example of a console app that runs
ok locally but will trip an exception if run from a network share. It
uses the following code in the Main() function...
PermissionSet fullTrust = new
PermissionSet(PermissionState.Unrestricted);
fullTrust.Demand();
...it worked fine, tripping an exception if called from a network
share, but not if called from a local drive.
I have a Windows Forms application that tries to access local disk
drives. I thought it would be good to add this code so that I can warn
the user that some functionality won't work if running from a network
share. So I added the code, copied the modified app to the network
share, ran it, and ***didn't*** get the message. The app then goes on
to give a FileIOPermission error when I try and access my c: drive.
I've since set up FileDialog and FileIO permissions in the
configuration tool which allows the WinForms app to access the local
drive, but it would be good to warn the user if this hasn't been done.
Why the difference in behaviour between WinForms and ConsoleApp ? What
have I misunderstood ?
TIA
Duke
- Next message: Toni: "Security error when loading plugin from shared folder."
- Previous message: Michel Gallant: "Re: Generate Public/Private Keys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|