SecurityAttribute.Unrestricted issue

拥有回忆 提交于 2019-11-30 19:04:30

问题


I am confused about this property, as mentioned here, http://msdn.microsoft.com/en-us/library/system.security.permissions.securityattribute.unrestricted.aspx we could give it full or non-full.

My confusion is for permission in a straightforward understanding, there should be only two status -- granted and not-granted, what does th full and non-full mean?


回答1:


I have previously used the Unrestricted attribute in the classic way:

The following code is a request stating that an assembly must have unrestricted access to the file system in order to function.

using System.Security.Permissions;
// Indicates that FileIOPermission is required to run this assembly.
[assembly:FileIOPermission(SecurityAction.RequestMinimum, Unrestricted=true)]
public class FileManager
{
// Insert code to add and delete files.
}

in this context Unrestricted=false would mean file access is not nessessarily required, for the method to execute.

as opposed to the 'oppisite' which would require that in order for the method to execute, file access must not be granted.

In most cases where the SecurityAction (Unrestricted=true||false) may be created dynamicaly, the first case usually makes more sense.



来源:https://stackoverflow.com/questions/1160146/securityattribute-unrestricted-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!