|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
about [SuppressUnmanagedCodeSecurity]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); } } } Hi Lloyd,
Show quote "Lloyd Dupont" <net.galador@ld> wrote in message You should apply [SuppressUnmanagedCodeSecurity] to P/Invoke functions or to 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); > } > } > } types implementing P/Invoke functions - not to types using them. 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. > |
|||||||||||||||||||||||