[英]Security Assembly Declaration does nothing?
I am trying to restrict the permissions my assembly has using Security Declarations. 我试图使用安全声明来限制程序集所具有的权限。 I have the follow example: 我有以下示例:
[assembly: UIPermission(SecurityAction.RequestOptional,Unrestricted = true)]
[assembly: FileIOPermission(SecurityAction.RequestOptional, Read = @"C:\Hello.txt")]
class Program
{
static void Main(string[] args)
{
// Create a file
TextWriter tw = new StreamWriter(@"C:\Hello.txt");
tw.WriteLine("Hello, world!");
tw.Close();
// Display the text of the file
TextReader tr = new StreamReader(@"C:\Hello.txt");
Console.WriteLine(tr.ReadToEnd());
tr.Close();
Console.ReadLine();
}
}
The second line in the main() is writing to the file that explicitly set to 'read only' permissions (at least I thought). main()中的第二行正在写入明确设置为“只读”权限的文件(至少我认为)。 Running this example does not result in a security exception thrown. 运行此示例不会导致引发安全异常。 Why is that? 这是为什么?
Thanks! 谢谢!
Presumably your app is running with full-trust. 大概您的应用程序正在完全信任地运行。 In full trust granular CAS permissions are not checked . 在完全信任状态下,不检查粒度CAS权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.