Export (0) Print
Expand All

Requesting Built-in Permission Sets

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.

Imports System
Imports System.Runtime.InteropServices
Imports System.Security.Permissions
'The attribute is placed at the assembly level.
<assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name := "FullTrust")>
Namespace MyNamespace
   Public Class [MyClass]
      Public Sub New()
      End Sub
      
      Public Sub MyMethod()
         'Perform operations that require permissions here.
      End Sub 
   End Class
End Namespace
[C#]
//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

Extending Metadata Using Attributes | Requesting Permissions | Code Access Security

Show:
© 2014 Microsoft