How would I use the SecurityPermissionAttribute correctly?
In an old project I came across 开发者_StackOverflow中文版the following assembly attribute:
[assembly: SecurityPermissionAttribute(SecurityAction.RequestMinimum, Execution = true)]
I understand that this attribute instructs the clr to not load this dll if the required permissions aren't available. Is it a good practice to include such declarations in your project as a default?
RequestMinimum
has never been very popular. In fact, most of the Code Access Security model never really gained much traction. Consequently, these areas were greatly reworked for .NET 4.0.
As of .NET 4.0, do not use RequestMinimum
because it will be ignored.
These changes are explained in detail in the documentation for .NET 4.0, http://msdn.microsoft.com/en-us/library/dd233103(VS.100).aspx.
精彩评论