How to: Request Permission for a Named Permission Set

Important noteImportant

In the .NET Framework version 4, runtime support has been removed for enforcing the Deny, RequestMinimum, RequestOptional, and RequestRefuse permission requests. Do not use these requests in code that is based on .NET Framework 4 or later. For more information about this and other changes, see Security Changes in the .NET Framework 4.

Instead of requesting individual permissions (using RequestMinimum, RequestOptional, or RequestRefuse), you can request any of the following built-in permission sets: Nothing, Execution, FullTrust, Internet, LocalIntranet, and SkipVerification. You cannot request custom named permission sets or the Everything modifiable built-in permission set because the permissions they represent can vary. The following example shows the syntax to request permission for a named permission set. It attaches a PermissionSetAttribute with a Name value representing the name of the desired permission set.

//The attribute is placed at the assembly level.
using System.Security.Permissions;
[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum, Name = "FullTrust")]
namespace MyNamespace
   using System;
   using System.Runtime.InteropServices;
   public class MyClass
      public MyClass()
      public void MyMethod()
      //Perform operations that require permissions here.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft