Re: Why unmanaged?
From: Ivan Medvedev [MS] (ivanmed_at_online.microsoft.com)
Date: Wed, 14 May 2003 09:20:03 -0700
We are trying to have as little permission classes as possible and at the
same time enough to cover all major scenarios. The need to protect
Application.Exit didn't seem enough a reason to grant creating a new
permission class just for that, so we looked at the "severity" of the Exit
opertaion and what it does under the hood and chose the UnmanagedCode
permission as the closest fit. ControlThread permission was designed to
protect thread operations, and exiting an application is something totally
different (for example, imaging a managed control on a page in the Internet
Explorer: it can be ok for it to create/abort threads, but it would never be
ok for it to exit the process, because managed controls are run in the IE
process). Basically, if we were creating a new permission for every
operation that needs to be protected we would have hundreds of those and it
all would be very confusing.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Guido Stinnez" <Guido.Stinnez@tria.de> wrote in message
> Thanks Ivan,
> that worked allright.
> I also found out in the meantime that the documentation
> was updated in 1.1 to the correct Permission.
> Still, though I understand that I may need a priviliged
> permission to call Application.Exit (like ControlThread
> for instance) - I'm still not directly calling Unmanaged
> Code. Maybe you could help me understand.
> Best regards, Guido
> >-----Original Message-----
> >Guido -
> >explicitly ending thread/process/application is a
> priviledged operation, so
> >it is normal that it is protected with a permission
> check. Use Form.Close()
> >to close your WinForms client.
> >This posting is provided "AS IS" with no warranties, and
> confers no rights.
> >"Guido Stinnez" <Guido.Stinnez@tria.de> wrote in message
> >> Hi!
> >> The Method Windows.Forms.Application.Exit() seems to
> >> require SecurityPermissionFlag.UnmanagedCode, while the
> >> documentation states that a UIPermission.AllWindows is
> >> that is needed.
> >> Someone seems to have forgotton to call an Assert ; )
> >> Does anyone know, whether this is a known issue and
> >> whether or not it will be fixed (and when)?
> >> It is quite uncomfortable not to be able to close my
> >> SmartClient and if I require the permission to call
> >> unmanaged code, I could just as well require FullTrust.
> >> Thx, Guido