Aracılığıyla paylaş


SecurityPermission Oluşturucular

Tanım

SecurityPermission sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

SecurityPermission(PermissionState)

Belirtilen şekilde kısıtlanmış veya kısıtlanmamış izinlerle sınıfının yeni bir örneğini SecurityPermission başlatır.

SecurityPermission(SecurityPermissionFlag)

Bayrakların belirtilen ilk küme durumuyla sınıfının yeni bir örneğini SecurityPermission başlatır.

SecurityPermission(PermissionState)

Kaynak:
SecurityPermission.cs
Kaynak:
SecurityPermission.cs
Kaynak:
SecurityPermission.cs
Kaynak:
SecurityPermission.cs

Belirtilen şekilde kısıtlanmış veya kısıtlanmamış izinlerle sınıfının yeni bir örneğini SecurityPermission başlatır.

public:
 SecurityPermission(System::Security::Permissions::PermissionState state);
public SecurityPermission (System.Security.Permissions.PermissionState state);
new System.Security.Permissions.SecurityPermission : System.Security.Permissions.PermissionState -> System.Security.Permissions.SecurityPermission
Public Sub New (state As PermissionState)

Parametreler

state
PermissionState

Değerlerden PermissionState biri.

Özel durumlar

state parametresi geçerli bir değeri PermissionStatedeğildir.

Açıklamalar

Tamamen kısıtlanmış (None) veya Unrestricted tüm güvenlik izinlerine erişim oluşturur.

Şunlara uygulanır

SecurityPermission(SecurityPermissionFlag)

Kaynak:
SecurityPermission.cs
Kaynak:
SecurityPermission.cs
Kaynak:
SecurityPermission.cs
Kaynak:
SecurityPermission.cs

Bayrakların belirtilen ilk küme durumuyla sınıfının yeni bir örneğini SecurityPermission başlatır.

public:
 SecurityPermission(System::Security::Permissions::SecurityPermissionFlag flag);
public SecurityPermission (System.Security.Permissions.SecurityPermissionFlag flag);
new System.Security.Permissions.SecurityPermission : System.Security.Permissions.SecurityPermissionFlag -> System.Security.Permissions.SecurityPermission
Public Sub New (flag As SecurityPermissionFlag)

Parametreler

flag
SecurityPermissionFlag

tarafından tanımlanan SecurityPermissionFlagherhangi bir izin bitinin bit düzeyinde VEYA birleşimiyle temsil edilen iznin ilk durumu.

Özel durumlar

flag parametresi geçerli bir değeri SecurityPermissionFlagdeğildir.

Örnekler

Aşağıdaki kod örneği, güvenlik izinleri talep etmek için kullanılan sınıfının örneklerini oluşturmak için oluşturucunun SecurityPermission kullanımını SecurityPermission gösterir. Kod örneğinin tamamı için oluşturucuya SecurityPermissionAttribute(SecurityAction) bakın.

static void DemandSecurityPermissions()
{
   Console::WriteLine( "\nExecuting DemandSecurityPermissions.\n" );
   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Assertion );
      Console::WriteLine( "Demanding SecurityPermissionFlag::Assertion" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::Assertion succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::Assertion failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlAppDomain );
      Console::WriteLine( "Demanding SecurityPermissionFlag::ControlAppDomain" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlAppDomain succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlAppDomain failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlDomainPolicy );
      Console::WriteLine( "Demanding SecurityPermissionFlag::ControlDomainPolicy" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlDomainPolicy succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlDomainPolicy failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlEvidence );
      Console::WriteLine( "Demanding SecurityPermissionFlag::ControlEvidence" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlEvidence succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlEvidence failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlPolicy );
      Console::WriteLine( "Demanding SecurityPermissionFlag::ControlPolicy" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPolicy succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPolicy failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlPrincipal );
      Console::WriteLine( "Demanding SecurityPermissionFlag::ControlPrincipal" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPrincipal succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPrincipal failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlThread );
      Console::WriteLine( "Demanding SecurityPermissionFlag::ControlThread" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlThread succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::ControlThread failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Execution );
      Console::WriteLine( "Demanding SecurityPermissionFlag::Execution" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::Execution succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::Execution failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Infrastructure );
      Console::WriteLine( "Demanding SecurityPermissionFlag::Infrastructure" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::Infrastructure succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::Infrastructure failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::RemotingConfiguration );
      Console::WriteLine( "Demanding SecurityPermissionFlag::RemotingConfiguration" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::RemotingConfiguration succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::RemotingConfiguration failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::SerializationFormatter );
      Console::WriteLine( "Demanding SecurityPermissionFlag::SerializationFormatter" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::SerializationFormatter succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::SerializationFormatter failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::SkipVerification );
      Console::WriteLine( "Demanding SecurityPermissionFlag::SkipVerification" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::SkipVerification succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::SkipVerification failed: {0}", e->Message );
   }

   try
   {
      SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::UnmanagedCode );
      Console::WriteLine( "Demanding SecurityPermissionFlag::UnmanagedCode" );
      sp->Demand();
      Console::WriteLine( "Demand for SecurityPermissionFlag::UnmanagedCode succeeded." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Demand for SecurityPermissionFlag::UnmanagedCode failed: {0}", e->Message );
   }

}
public static void DemandSecurityPermissions()
{
    Console.WriteLine("\nExecuting DemandSecurityPermissions.\n");
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.Assertion);
        Console.WriteLine("Demanding SecurityPermissionFlag.Assertion");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.Assertion succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.Assertion failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.ControlAppDomain);
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlAppDomain");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlAppDomain succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlAppDomain failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.ControlDomainPolicy);
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlDomainPolicy");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlDomainPolicy succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlDomainPolicy failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.ControlEvidence);
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlEvidence");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlEvidence succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlEvidence failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.ControlPolicy);
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlPolicy");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlPolicy succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlPolicy failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.ControlPrincipal);
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlPrincipal");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlPrincipal succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlPrincipal failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.ControlThread);
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlThread");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlThread succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlThread failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.Execution);
        Console.WriteLine("Demanding SecurityPermissionFlag.Execution");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.Execution succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.Execution failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.Infrastructure);
        Console.WriteLine("Demanding SecurityPermissionFlag.Infrastructure");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.Infrastructure succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.Infrastructure failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.RemotingConfiguration);
        Console.WriteLine("Demanding SecurityPermissionFlag.RemotingConfiguration");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.RemotingConfiguration succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.RemotingConfiguration failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.SerializationFormatter);
        Console.WriteLine("Demanding SecurityPermissionFlag.SerializationFormatter");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.SerializationFormatter succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.SerializationFormatter failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.SkipVerification);
        Console.WriteLine("Demanding SecurityPermissionFlag.SkipVerification");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.SkipVerification succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.SkipVerification failed: " + e.Message);
    }
    try
    {
        SecurityPermission sp =
            new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
        Console.WriteLine("Demanding SecurityPermissionFlag.UnmanagedCode");
        sp.Demand();
        Console.WriteLine("Demand for SecurityPermissionFlag.UnmanagedCode succeeded.");
    }
    catch (Exception e)
    {
        Console.WriteLine("Demand for SecurityPermissionFlag.UnmanagedCode failed: " + e.Message);
    }
}
Public Shared Sub DemandSecurityPermissions()
    Console.WriteLine(ControlChars.Lf & "Executing DemandSecurityPermissions." & ControlChars.Lf)
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.Assertion)
        Console.WriteLine("Demanding SecurityPermissionFlag.Assertion")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.Assertion succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.Assertion failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlAppDomain)
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlAppDomain")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlAppDomain succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.ControlAppDomain failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlDomainPolicy)
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlDomainPolicy")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlDomainPolicy succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.ControlDomainPolicy failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlEvidence)
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlEvidence")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlEvidence succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.ControlEvidence failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlPolicy)
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlPolicy")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlPolicy succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.ControlPolicy failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlPrincipal)
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlPrincipal")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlPrincipal succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.ControlPrincipal failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlThread)
        Console.WriteLine("Demanding SecurityPermissionFlag.ControlThread")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.ControlThread succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.ControlThread failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.Execution)
        Console.WriteLine("Demanding SecurityPermissionFlag.Execution")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.Execution succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.Execution failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.Infrastructure)
        Console.WriteLine("Demanding SecurityPermissionFlag.Infrastructure")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.Infrastructure succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.Infrastructure failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.RemotingConfiguration)
        Console.WriteLine("Demanding SecurityPermissionFlag.RemotingConfiguration")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.RemotingConfiguration succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.RemotingConfiguration failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.SerializationFormatter)
        Console.WriteLine("Demanding SecurityPermissionFlag.SerializationFormatter")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.SerializationFormatter succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.SerializationFormatter failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.SkipVerification)
        Console.WriteLine("Demanding SecurityPermissionFlag.SkipVerification")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.SkipVerification succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.SkipVerification failed: " & e.Message))
    End Try
    Try
        Dim sp As New SecurityPermission(SecurityPermissionFlag.UnmanagedCode)
        Console.WriteLine("Demanding SecurityPermissionFlag.UnmanagedCode")
        sp.Demand()
        Console.WriteLine("Demand for SecurityPermissionFlag.UnmanagedCode succeeded.")
    Catch e As Exception
        Console.WriteLine(("Demand for SecurityPermissionFlag.UnmanagedCode failed: " & e.Message))
    End Try
End Sub

Şunlara uygulanır