Tech Off Thread

10 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

FileIOPermission Problem

Back to Forum: Tech Off
  • User profile image
    Secret​Software

    ok I am trying to get all files in a given directory.
    Using the Directory.GetFiles (path).
    The code compiles ok, but then at runtimes, a security exception happens
       >>>Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0,etc..
    what do I have to do to get around that?

    thanks

  • User profile image
    JohnAskew

    Your assembly should request permission for reading files; commonly a network share.

    Use an Attribute for this above your namespace, something similar to this:

    using System.Security.Permissions;

    [assembly:FileIOPermission(SecurityAction.RequestMinimum, Read=@"C:\boot.ini")]

  • User profile image
    amd_duron

    If you are on a shared host doing this, you may be trying to access files outside your application directory and failing because it is locked there by the trust config Smiley  

  • User profile image
    Secret​Software

    The assembly, is really an add-in for msn messnger.  All it does is to read images from a given directory, and then loop through them , and display them in the display. So if you want to show your friend your pictures, it does this automatically. The code is good, but the security permission is the problem. Msn messenger does not allow it to do that for some reason?

  • User profile image
    Secret​Software

    This problem is inherrent into the Msn Messenger Client. So the messenger team will have to solve it.

  • User profile image
    RichardRudek

    SecretSoftware wrote:
    This problem is inherrent into the Msn Messenger Client. So the messenger team will have to solve it.


    In which case, it sounds like this is by design - security, and all that, as talked about in the [Windows Live Video].

    EDIT: The sand-boxing is talked about on [Katie's Blog].

  • User profile image
    Secret​Software

    RichardRudek wrote:
    
    SecretSoftware wrote: This problem is inherrent into the Msn Messenger Client. So the messenger team will have to solve it.


    In which case, it sounds like this is by design - security, and all that, as talked about in the [Windows Live Video].

    EDIT: The sand-boxing is talked about on [Katie's Blog].


    Yes, in Katie's blog I see people complaining about the FileIOPermission. It appears that Msn Messenger Client, will not allow you to load your Assembly add-in , if the assembly has higher security access attribute that what msn accepts. So your pretty much cant do much but change your Personal Status message and your display picture (through having the computer generate randomal Bitmap). No access to the File System what so ever. No way to get around it unless MS allows it.

    On one hand I understand why they did that, its for disallowing malicous users from using Messenger to launch Zombie networks or viruses. But then what about the good users who wish to do some cool things with Add-Ins? There must be a way and a compropmise between having a really good security and allowing us, to develop useful add-ins.

  • User profile image
    Sven Groot

    Since it says the add-ons are running in the Internet zone, you can use IsolatedStorage to save settings and stuff like that, and also have FileDialogPermission; this means you can use an OpenFileDialog to ask a user to specify a file and then open it using OpenFileDialog.OpenFile.

  • User profile image
    Secret​Software

    Sven Groot wrote:
    Since it says the add-ons are running in the Internet zone, you can use IsolatedStorage to save settings and stuff like that, and also have FileDialogPermission; this means you can use an OpenFileDialog to ask a user to specify a file and then open it using OpenFileDialog.OpenFile.


    You cannot. After the user selects the file and press ok, you get an Access Permission exception.

  • User profile image
    Sven Groot

    SecretSoftware wrote:
    
    Sven Groot wrote: Since it says the add-ons are running in the Internet zone, you can use IsolatedStorage to save settings and stuff like that, and also have FileDialogPermission; this means you can use an OpenFileDialog to ask a user to specify a file and then open it using OpenFileDialog.OpenFile.


    You cannot. After the user selects the file and press ok, you get an Access Permission exception.

    Hmm, you shouldn't, as long as all you use is the OpenFile method. You can't retrieve the filename.

    Unless they're really using more restricted settings than even the Internet zone.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.