Home All Groups Group Topic Archive Search About

about [SuppressUnmanagedCodeSecurity]

Author
10 Jun 2006 2:57 AM
Lloyd Dupont
I'm not exactly sur in which context it is valid / usefull.

For example will it suppres the stack in the following sample below when
using the ScreenGraphics class?
(i.e. I wonder if it will work even if it is not applied to the Gdi32 class,
but to the "consumer" class ScreenGraphics instead...)

internal static class Gdi32
{
    [DllExport("GDI32")]
    public static extern IntPtr GetHdc(IntPtr hWnd);
}
[SuppressUnmanagedCodeSecurity]
public class ScreenGraphics
{
    public Graphics Graphics
    {
         get
        {
            IntPtr hdc = Gdi32.GetHdc(IntPtr.Zero);
            return Graphics.FromHdc(hdc);
        }
    }
}

Author
10 Jun 2006 5:23 AM
Marcus Heege
Hi Lloyd,

Show quote
"Lloyd Dupont" <net.galador@ld> wrote in message
news:euUgImDjGHA.1208@TK2MSFTNGP02.phx.gbl...
> I'm not exactly sur in which context it is valid / usefull.
>
> For example will it suppres the stack in the following sample below when
> using the ScreenGraphics class?
> (i.e. I wonder if it will work even if it is not applied to the Gdi32
> class, but to the "consumer" class ScreenGraphics instead...)
>
> internal static class Gdi32
> {
>    [DllExport("GDI32")]
>    public static extern IntPtr GetHdc(IntPtr hWnd);
> }
> [SuppressUnmanagedCodeSecurity]
> public class ScreenGraphics
> {
>    public Graphics Graphics
>    {
>         get
>        {
>            IntPtr hdc = Gdi32.GetHdc(IntPtr.Zero);
>            return Graphics.FromHdc(hdc);
>        }
>    }
> }

You should apply [SuppressUnmanagedCodeSecurity] to P/Invoke functions or to
types implementing P/Invoke functions - not to types using them.
Author
10 Jun 2006 6:30 AM
Lloyd Dupont
Hi Marcus,
Thanks for the information!
Too bad for the info itself :-(

Show quote
"Marcus Heege" <NOSPAM@heege.net> wrote in message
news:ev7CR4EjGHA.4368@TK2MSFTNGP03.phx.gbl...
> Hi Lloyd,
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:euUgImDjGHA.1208@TK2MSFTNGP02.phx.gbl...
>> I'm not exactly sur in which context it is valid / usefull.
>>
>> For example will it suppres the stack in the following sample below when
>> using the ScreenGraphics class?
>> (i.e. I wonder if it will work even if it is not applied to the Gdi32
>> class, but to the "consumer" class ScreenGraphics instead...)
>>
>> internal static class Gdi32
>> {
>>    [DllExport("GDI32")]
>>    public static extern IntPtr GetHdc(IntPtr hWnd);
>> }
>> [SuppressUnmanagedCodeSecurity]
>> public class ScreenGraphics
>> {
>>    public Graphics Graphics
>>    {
>>         get
>>        {
>>            IntPtr hdc = Gdi32.GetHdc(IntPtr.Zero);
>>            return Graphics.FromHdc(hdc);
>>        }
>>    }
>> }
>
> You should apply [SuppressUnmanagedCodeSecurity] to P/Invoke functions or
> to types implementing P/Invoke functions - not to types using them.
>

AddThis Social Bookmark Button