Re: Security Exception when I use IsolatedStorageFilePermissionAtt

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Chris Tanger (chrisNnOoSsPpAaMmtanger_at_technocisive.com)
Date: 10/25/04


Date: Sun, 24 Oct 2004 19:01:06 -0700


    You are right! It does make sense now that I know that optional not only
requests optional permissions but also requests a refusal of everything else.
   I am just try to make an application that will be usable with the default
"internet" permission set. This way my application can be run by users even
if they don't trust it very much. I needed the optional permissions in case
they decide they do trust my application and want the extra functionality
"Save results to file" using SaveFileDialog.

Thanks,

-Chris

"Richard Blewett [DevelopMentor]" wrote:

> OK, the RequestMinimum and RequestOptional don't work *exactly* as you'd expect. Once you understand what they are doing it makes snese, its just not necessarily what you would expect.
>
> RequestMinimum says if I don't have these permissions please fail to load me (this ones fairly straightforward). Its a way to make sure you get a load time failure rather than during execution if you don't have a permission that your assembly cannot do without.
>
> RequestOptional is more tricky. It is always used in conjunction with RequestMinimum and says: RequestMinimum says we need these permissions but I also happy to run with these other ones too. Anything outside of the union of these permissions *I don't want to be granted*. So if you have any RequestOptional permissions anything outside of the union of RequestMinimum and RequestOptional will not be granted to your assembly.
>
> In your case you have essentially stated that apart from access to File Dialogs, File IO and Isolated Storage *you don't want any other permissions granted to you* and so you will fail to get the UIPermission.
>
> What are you trying to achieve with the RequestOptional permissions?
>
> Regards
>
> Richard Blewett - DevelopMentor
> http://staff.develop.com/richardb/weblog
>
>
> I have a simple windows application that I wish to be able to run on
> machines that don't trust it. The application is simply a sort of calculator
> that needs to be able to export and import results to files of the user's
> choosing. The application should also be able to save user preferences like
> control sizing.
> None of that is relevant because the application throws a security
> exception before it even gets to any of the file saving code. I have the
> following lines at the bottom of my AssemblyInfo.cs file:
> [assembly:FileDialogPermissionAttribute(SecurityAction.RequestMinimum,
> Unrestricted=true)]
> [assembly:FileIOPermissionAttribute(SecurityAction.RequestOptional,
> Unrestricted=true)] [assembly:IsolatedStorageFilePermissionAttribute(SecurityAction.RequestOptional, Unrestricted=true)]
>
> I get a the following exception message when I run it in debug in visual
> studio:
> An unhandled exception of type 'System.Security.SecurityException' occurred
> in mscorlib.dll
> Additional information: Request for the permission of type
> System.Security.Permissions.UIPermission ...
>
> Commenting out either the second or the third line still leads to the
> exception, however, if I comment out BOTH the second and the third line
> everything is OK. What I really don't understand is why do I get a
> UIPermission exception when those lines have nothing to do with
> UIPermissions. Can anyone tell me why I am getting this error and how to fix
> the problem.
> I believe this should be reproducible on any windows forms .NET 2003
> application. Simply paste the three "[assembly:..." lines above into the
> bottom of your AssemblyInfo.cs file.
>
>
>



Relevant Pages

  • RE: Excel Open throws 0x800A03EC error
    ... I need to give permissions to Microsoft Excel Application which was missing ... I did the following to give Excel permissions. ... General Information ... Exception Type: System.Runtime.InteropServices.COMException ...
    (microsoft.public.office.developer.automation)
  • RE: Error when attaching multiple files (System.web.mail)
    ... Settings folder on your machine to the authenticated domain user account. ... Try to give permissions to ASPNET user account on the local folder where ... you are storing your attachments. ... > following exception. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RWW
    ... Were the permissions correct, or did you have to adjust them? ... >> Add Local Service and Network Service account Read & Execute, ... >>> current web request. ... >>> Exception Details: System.UnauthorizedAccessException: Access to the ...
    (microsoft.public.windows.server.sbs)
  • Re: how can I run .net logon script application
    ... What about the other exception? ... > CodeBase: ... >> A PolicyException can be addressed by adjusting the CAS policy. ... >> Windows permissions to run your code, ...
    (microsoft.public.dotnet.security)
  • Excel Open throws 0x800A03EC error
    ... I need to give permissions to Microsoft Excel Application which was missing ... I did the following to give Excel permissions. ... General Information ... Exception Type: System.Runtime.InteropServices.COMException ...
    (microsoft.public.office.developer.automation)