Security.PermissionSet via Console and Windows Forms

From: Duke (d_dejanews_at_yahoo.co.uk)
Date: 05/26/04


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



Relevant Pages

  • Re: Drive box returns wrong case?
    ... compare text to my app and various string values with varying ... DirListBox to allow the user to find a folder in which a search begins ... This app is looking at remote drives across a network in case that has ...
    (microsoft.public.vb.general.discussion)
  • Re: Multiple network drives to same letter?
    ... > We have some legacy applications that expect drives to be mapped to ... > particular locations on the network. ... App A requires drive F: ... > Is there any way to have drives mapped to a windows application instance ...
    (microsoft.public.windowsxp.basics)
  • Multiple network drives to same letter?
    ... particular locations on the network. ... you can ony use one ... App A requires drive F: ... Is there any way to have drives mapped to a windows application instance ...
    (microsoft.public.windowsxp.basics)
  • Re: CD-ROM detection by application in "local devices"
    ... However vendors of the applications you mention usually have a network edtion that allows the files to be stored on the network. ... but rather of the 'Network Drives' 'cd-rom on ' ... to the app on the TerminalServer as it were a local CD-ROM? ...
    (microsoft.public.windows.terminal_services)
  • Re: Sqlserverce class not working when VB.Net application is running from network drive
    ... The issue is that if more than one app attempts to connect to a sdf file on a network share, the first app that connections opens that file with an exclusive handle so no other apps can access it. ... >> possible that the database is already in use when you attempt to ... >>> network drives. ...
    (microsoft.public.sqlserver.ce)