SecurityException Sınıf
Tanım
Bir güvenlik hatası algılandığında oluşturulan özel durum.The exception that is thrown when a security error is detected.
public ref class SecurityException : Exception
public ref class SecurityException : SystemException
public class SecurityException : Exception
public class SecurityException : SystemException
[System.Serializable]
public class SecurityException : SystemException
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class SecurityException : SystemException
type SecurityException = class
inherit Exception
type SecurityException = class
inherit SystemException
[<System.Serializable>]
type SecurityException = class
inherit SystemException
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type SecurityException = class
inherit SystemException
Public Class SecurityException
Inherits Exception
Public Class SecurityException
Inherits SystemException
- Devralma
- Devralma
- Öznitelikler
Açıklamalar
Bir SecurityException arayan bir kaynağa erişmek için gerekli izinlere sahip olmadığında bir özel durum oluşturulur.A SecurityException exception is thrown when a caller does not have the permissions required to access a resource. Aşağıdaki örnek, PermissionSet UIPermission RegistryPermission kayıt defteri ERIŞIMINI engellemek için UI nesnelerine ve panosuna ve bir nesneye erişime izin veren bir nesnesi içeren bir nesne oluşturur.The following example instantiates a PermissionSet object that includes a UIPermission object to allow access to UI objects and the Clipboard and a RegistryPermission object to prevent registry access. Yöntemine yapılan çağrı, PermissionSet.PermitOnly Bu izinlerin çağırana atanan izinlerle ne olursa olsun uygulanacağını gösterir.The call to the PermissionSet.PermitOnly method means that these permissions will apply regardless of the permissions assigned to the caller. Sonuç olarak, kayıt defteri anahtarı oluşturma girişimi bir oluşturur SecurityException .As a result, the attempt to create a registry key throws a SecurityException.
using Microsoft.Win32;
using System;
using System.Security;
using System.Security.Permissions;
public class Example
{
public static void Main()
{
PermissionSet perms = new PermissionSet(null);
perms.AddPermission(new UIPermission(PermissionState.Unrestricted));
perms.AddPermission(new RegistryPermission(PermissionState.None));
perms.PermitOnly();
try {
RegistryKey key = Registry.CurrentUser.CreateSubKey("MyCompany\\Applications");
Console.WriteLine("Registry key: {0}", key.Name);
}
catch (SecurityException e) {
Console.WriteLine("Security Exception:\n\n{0}", e.Message);
}
}
}
// The example displays the following output:
// Security Exception:
//
// Request for the permission of type 'System.Security.Permissions.RegistryPermission,
// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Imports Microsoft.Win32
Imports System.Security
Imports System.Security.Permissions
Module Example
Public Sub Main()
Dim perms As New PermissionSet(CType(Nothing, PermissionSet))
perms.AddPermission(New UIPermission(PermissionState.Unrestricted))
perms.AddPermission(New RegistryPermission(PermissionState.None))
perms.PermitOnly()
Try
Dim key As RegistryKey = Registry.CurrentUser.CreateSubKey("MyCompany\\Applications")
Console.WriteLine("Registry key: {0}", key.Name)
Catch e As SecurityException
Console.WriteLine("Security Exception:\n\n{0}", e.Message)
End Try
End Sub
End Module
' The example displays the following output:
' Security Exception:
'
' Request for the permission of type 'System.Security.Permissions.RegistryPermission,
' mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
SecurityException 0x8013150A değerine sahip olan HRESULT COR_E_SECURITY kullanır.SecurityException uses the HRESULT COR_E_SECURITY, which has the value 0x8013150A.
Sınıfının bir örneği için ilk özellik değerlerinin listesi için SecurityException , bkz. belirli bir SecurityException Oluşturucu.For a list of the initial property values for an instance of the SecurityException class, see a specific SecurityException constructor.
Oluşturucular
SecurityException() |
Varsayılan özelliklerle sınıfının yeni bir örneğini başlatır SecurityException .Initializes a new instance of the SecurityException class with default properties. |
SecurityException(SerializationInfo, StreamingContext) |
SecurityException sınıfının yeni bir örneğini serileştirilmiş verilerle başlatır.Initializes a new instance of the SecurityException class with serialized data. |
SecurityException(String) |
Belirtilen bir hata iletisiyle sınıfın yeni bir örneğini başlatır SecurityException .Initializes a new instance of the SecurityException class with a specified error message. |
SecurityException(String, AssemblyName, PermissionSet, PermissionSet, MethodInfo, SecurityAction, Object, IPermission, Evidence) |
SecurityExceptionYetersiz izin kümesi nedeniyle oluşan bir özel durum için sınıfının yeni bir örneğini başlatır.Initializes a new instance of the SecurityException class for an exception caused by an insufficient grant set. |
SecurityException(String, Exception) |
SecurityExceptionBelirtilen bir hata iletisiyle sınıfın yeni bir örneğini ve bu özel durumun nedeni olan iç özel duruma bir başvuruyu başlatır.Initializes a new instance of the SecurityException class with a specified error message and a reference to the inner exception that is the cause of this exception. |
SecurityException(String, Object, Object, MethodInfo, Object, IPermission) |
SecurityExceptionYığın üzerinde reddetme nedeniyle oluşan özel durum için sınıfın yeni bir örneğini başlatır.Initializes a new instance of the SecurityException class for an exception caused by a Deny on the stack. |
SecurityException(String, Type) |
SecurityExceptionBelirtilen bir hata iletisi ve özel durumun oluşturulmasına neden olan izin türü ile sınıfın yeni bir örneğini başlatır.Initializes a new instance of the SecurityException class with a specified error message and the permission type that caused the exception to be thrown. |
SecurityException(String, Type, String) |
SecurityExceptionBelirtilen bir hata iletisiyle sınıfın yeni bir örneğini, özel durumun oluşturulmasına neden olan izin türünü ve izin durumunu başlatır.Initializes a new instance of the SecurityException class with a specified error message, the permission type that caused the exception to be thrown, and the permission state. |
Özellikler
Action |
Özel duruma neden olan güvenlik eylemini alır veya ayarlar.Gets or sets the security action that caused the exception. |
Data |
Özel durum hakkında ek kullanıcı tanımlı bilgiler sağlayan anahtar/değer çiftleri koleksiyonunu alır.Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Devralındığı yer: Exception) |
Demanded |
İstenen güvenlik izni, izin kümesi ya da başarısız olan izin kümesi koleksiyonunu alır veya ayarlar.Gets or sets the demanded security permission, permission set, or permission set collection that failed. |
DenySetInstance |
Engellenen güvenlik iznini, izin kümesini veya izin kümesi koleksiyonunu alır veya ayarlar.Gets or sets the denied security permission, permission set, or permission set collection that caused a demand to fail. |
FailedAssemblyInfo |
Başarısız bütünleştirilmiş kod hakkındaki bilgileri alır veya ayarlar.Gets or sets information about the failed assembly. |
FirstPermissionThatFailed |
İzin kümesi veya izin kümesi koleksiyonundaki isteği başarısız olan ilk izni alır veya ayarlar.Gets or sets the first permission in a permission set or permission set collection that failed the demand. |
GrantedSet |
Öğesine neden olan derlemenin verilen izin kümesini alır veya ayarlar SecurityException .Gets or sets the granted permission set of the assembly that caused the SecurityException. |
HelpLink |
Bu özel durumla ilişkili Yardım dosyasının bağlantısını alır veya ayarlar.Gets or sets a link to the help file associated with this exception. (Devralındığı yer: Exception) |
HResult |
Belirli bir özel duruma atanan kodlanmış bir sayısal değer olan HRESULT 'yi alır veya ayarlar.Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Devralındığı yer: Exception) |
InnerException |
ExceptionGeçerli özel duruma neden olan örneği alır.Gets the Exception instance that caused the current exception. (Devralındığı yer: Exception) |
Message |
Geçerli özel durumu açıklayan bir ileti alır.Gets a message that describes the current exception. (Devralındığı yer: Exception) |
Method |
Özel durumla ilişkili yöntemi hakkındaki bilgileri alır veya ayarlar.Gets or sets the information about the method associated with the exception. |
PermissionState |
Özel durumu oluşturan iznin durumunu alır veya ayarlar.Gets or sets the state of the permission that threw the exception. |
PermissionType |
Başarısız olan iznin türünü alır veya ayarlar.Gets or sets the type of the permission that failed. |
PermitOnlySetInstance |
Bir güvenlik denetiminin başarısız olmasına neden olan yalnızca izin yığını çerçevesinin bir parçası olan izin, izin kümesi veya izin kümesi koleksiyonunu alır veya ayarlar.Gets or sets the permission, permission set, or permission set collection that is part of the permit-only stack frame that caused a security check to fail. |
RefusedSet |
Öğesine neden olan derlemenin reddedilen izin kümesini alır veya ayarlar SecurityException .Gets or sets the refused permission set of the assembly that caused the SecurityException. |
Source |
Uygulamanın veya hataya neden olan nesnenin adını alır veya ayarlar.Gets or sets the name of the application or the object that causes the error. (Devralındığı yer: Exception) |
StackTrace |
Çağrı yığınında anlık çerçevelerin dize gösterimini alır.Gets a string representation of the immediate frames on the call stack. (Devralındığı yer: Exception) |
TargetSite |
Geçerli özel durumu oluşturan yöntemi alır.Gets the method that throws the current exception. (Devralındığı yer: Exception) |
Url |
Özel duruma neden olan derlemenin URL 'sini alır veya ayarlar.Gets or sets the URL of the assembly that caused the exception. |
Zone |
Özel duruma neden olan derlemenin bölgesini alır veya ayarlar.Gets or sets the zone of the assembly that caused the exception. |
Yöntemler
Equals(Object) |
Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.Determines whether the specified object is equal to the current object. (Devralındığı yer: Object) |
GetBaseException() |
Türetilmiş bir sınıfta geçersiz kılınırsa, Exception bir veya daha fazla sonraki özel durumun kök nedeni olan öğesini döndürür.When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Devralındığı yer: Exception) |
GetHashCode() |
Varsayılan karma işlevi olarak işlev görür.Serves as the default hash function. (Devralındığı yer: Object) |
GetObjectData(SerializationInfo, StreamingContext) |
SerializationInfoİle hakkındaki bilgileri ayarlar SecurityException .Sets the SerializationInfo with information about the SecurityException. |
GetObjectData(SerializationInfo, StreamingContext) |
Türetilmiş bir sınıfta geçersiz kılınırsa, SerializationInfo özel durum hakkındaki bilgileri ayarlar.When overridden in a derived class, sets the SerializationInfo with information about the exception. (Devralındığı yer: Exception) |
GetType() |
Geçerli örneğin çalışma zamanı türünü alır.Gets the runtime type of the current instance. (Devralındığı yer: Exception) |
MemberwiseClone() |
Geçerli bir basit kopyasını oluşturur Object .Creates a shallow copy of the current Object. (Devralındığı yer: Object) |
ToString() |
Geçerli öğesinin gösterimini döndürür SecurityException .Returns a representation of the current SecurityException. |
Ekinlikler
SerializeObjectState |
Özel durum hakkında serileştirilmiş veri içeren bir özel durum nesnesi oluşturmak için bir özel durum serileştirildiğinde gerçekleşir.Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. (Devralındığı yer: Exception) |