Re: Check for permission does not work

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

From: Marius Groenendijk ("Marius)
Date: 11/02/04


Date: Tue, 2 Nov 2004 10:16:12 +0100

Thanks Nicole! That did it.

"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:uI6e$JdvEHA.536@TK2MSFTNGP11.phx.gbl...
> Marius,
>
> Demands just check the callers on the stack, not the current method. If
> you're running this from you application's Main method, you'll probably
> find the result you expect if you move this code into a separate method
> that can be called from Main.
>
> HTH,
> Nicole
>
>
> "Marius Groenendijk" <M (underscore) Groenendijk At (VeryWarm) Mail> wrote
> in message news:eoawkrcvEHA.3612@TK2MSFTNGP09.phx.gbl...
>> Hi group,
>>
>> I want my app to show a msg if my it doesn't have the required
>> permission(s), however this simply doesn't work.
>>
>> What am I overlooking/doing wrong??
>>
>> [VB.NET]
>> Try
>> Dim x As New SecurityPermission(SecurityPermissionFlag.UnmanagedCode)
>> x.Flags = Security.Permissions.SecurityPermissionFlag.UnmanagedCode
>> x.Demand()
>> MessageBox.Show("YES UnmanagedCode permission")
>> Catch ex As Exception
>> MessageBox.Show("NO UnmanagedCode permission")
>> ' application.exit
>> End Try
>>
>> To ensure that my app doesn't have UnmanagedCode permission I run it from
>> a network share. But the app always claims to have unmanaged permission.
>> Trying a pinvoke (=unmanaged) for instance gives a security exception.
>>
>> TIA,
>> Marius.
>>
>>
>>
>>
>
>



Relevant Pages

  • Re: Check for permission does not work
    ... Demands just check the callers on the stack, ... > To ensure that my app doesn't have UnmanagedCode permission I run it from ... > Trying a pinvoke for instance gives a security exception. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Check for permission does not work
    ... Demands just check the callers on the stack, ... > To ensure that my app doesn't have UnmanagedCode permission I run it from ... > Trying a pinvoke for instance gives a security exception. ...
    (microsoft.public.dotnet.security)
  • Re: Check for permission does not work
    ... > Demands just check the callers on the stack, ... >> To ensure that my app doesn't have UnmanagedCode permission I run it from ... >> Marius. ...
    (microsoft.public.dotnet.security)
  • Re: Check for permission does not work
    ... The following sample throws a security ... exception when it demands the UnmanagedCode permission. ... > To ensure that my app doesn't have UnmanagedCode permission I run it from ...
    (microsoft.public.dotnet.security)
  • Re: Check for permission does not work
    ... The following sample throws a security ... exception when it demands the UnmanagedCode permission. ... > To ensure that my app doesn't have UnmanagedCode permission I run it from ...
    (microsoft.public.dotnet.languages.vb)