简体   繁体   中英

Color.FromArgb(…); security message

I am defining a Color from argb , ex

Color.FromArgb(255,255,0,0);

In visual studio 2012 , winRT application it says that this is tagged with [security critical] . Are there any reasons why? I tried searching, no results. And no idea why this relates to security.

Update:

Now I notice, not only does FromArgb(...); methods gives this [SECURITY CRITICAL] warning. any of these:

c.A = 255;
c.R = 255;
c.G = 0;
c.B = 0;

Also does.

System.Drawing is a wrapper around unmanaged GDI+ code. From my understanding, WinRT does not support GDI+:

http://social.msdn.microsoft.com/Forums/en-NZ/winappswithnativecode/thread/0ba00fbd-183f-4df6-afa2-04d0ac14706a

Native rendering code will need to be done with Direct2D.

Your message is not a Warning , is information about method signature attribute.

SECURITY CRITICAL is a code Attribute wich real class name is SecurityCriticalAttribute. This attribute must be given to methods thats need full trust to execute code ( usually native code calls, unsafe code, graphics resources (wich usually needs unmanaged code etc.) ).

If methods are not granted full trust the Security Critical method raise an exception.

more info: http://msdn.microsoft.com/en-us/library/system.security.securitycriticalattribute.aspx

您应该使用System.Windows.MediaColor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM