System.Security.Permissions.FileIOPermission Exception

There is a user control Which has functionalities of open any image file from user machine and allow user to apply effects and filters on it. This control is working fine if I place it on windows forms application. I am getting 

 "file ,System.Security.Permissions.FileIOPermission,mscorlib,version ,PublicKeyToken=b77ka323adgf2e23 failed"

 exception  if I placed same on  a Html page and tried to open a picture .How to solve it


Answer this question

System.Security.Permissions.FileIOPermission Exception

  • Martin_Saucier

    There are a few ways to solve this, ranging from easiest and most dangerous to most difficult and safest.  By default, the intranet security zone is running in a sandbox, and therefore doesn't have FileIOPermissions among other things.  There is a good explanation of the zones and how to grant full-trust to the intranet zone here:  <a href="http://samples.gotdotnet.com/quickstart/howto/doc/security/SecScripting.aspx">Script security policy changes</a>.  Obviously, by doing this, you could browse to a malicious page on your intranet that will get full-control of your machine.

    If the user control is signed, you could grant permissions to the signer of the control (also covered in the link).  

    The safest method is to just grant full-trust to the assembly that contains the user control.  You can do this by running mmc.exe, and opening the mscorcfg.msc in your \windows\microsoft.net\framework\<version>\ directory.  Choose the Configure Code Access Security link.  Click Increase Assembly Trust, and follow the wizard to grant your assembly full-trust.

    Bri 

  • System.Security.Permissions.FileIOPermission Exception