简体   繁体   English

安全大会宣言什么都不做?

[英]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.

相关问题 System.Security.SecurityException:该程序集不允许部分信任的调用者 - System.Security.SecurityException: That assembly does not allow partially trusted callers System.Security.SecurityException:该程序集不允许部分信任的调用者 - System.Security.SecurityException: That assembly does not allow partially trusted callers .NET程序集插件安全性 - .NET Assembly Plugin Security Assembly.CreateInstance和安全性 - Assembly.CreateInstance and security .net程序集安全性问题 - .net Assembly security question 类型或名称空间名称“ OpenIdConnect”在名称空间“ Microsoft.Owin.Security”中不存在(您是否缺少程序集引用?) - The type or namespace name 'OpenIdConnect' does not exist in the namespace 'Microsoft.Owin.Security' (are you missing an assembly reference?) C#-名称空间“ Windows”中不存在类型或名称空间名称“ Security”(您是否缺少程序集引用?) - C# - The type or namespace name 'Security' does not exist in the namespace 'Windows' (are you missing an assembly reference?) 程序集声明安全性-请求可选 - Assembly Declarative Security - Request Optional 将程序集声明从C#转换为VB - Translate assembly declaration from C# to VB Xamarin自定义渲染器中的装配声明 - Assembly declaration in Xamarin's custom renderers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM