Export (0) Print
Expand All

How to: Request Permission for a Named Permission Set 

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.

Example

//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.
      }
   }
}

See Also

Community Additions

ADD
Show:
© 2014 Microsoft