SecurityException 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 SecurityException 类的新实例。
重载
| 名称 | 说明 |
|---|---|
| SecurityException() |
使用默认属性初始化类的新实例 SecurityException 。 |
| SecurityException(String) |
使用指定的错误消息初始化类的新实例 SecurityException 。 |
| SecurityException(SerializationInfo, StreamingContext) |
已过时.
使用序列化的数据初始化 SecurityException 类的新实例。 |
| SecurityException(String, Exception) |
使用指定的错误消息和对作为此异常原因的内部异常的引用初始化 SecurityException 类的新实例。 |
| SecurityException(String, Type) |
使用指定的错误消息和导致引发异常的权限类型初始化类的新实例 SecurityException 。 |
| SecurityException(String, Type, String) |
使用指定的错误消息、导致引发异常的权限类型以及权限状态初始化类的新实例 SecurityException 。 |
| SecurityException(String, Object, Object, MethodInfo, Object, IPermission) |
为堆栈上的 Deny 导致的异常初始化类的新实例 SecurityException 。 |
| SecurityException(String, AssemblyName, PermissionSet, PermissionSet, MethodInfo, SecurityAction, Object, IPermission, Evidence) |
初始化由授予集不足导致的异常的类的新实例 SecurityException 。 |
示例
有关使用 SecurityException 构造函数的示例,请参阅为 SecurityException(String, Object, Object, MethodInfo, Object, IPermission) 构造函数提供的示例。
SecurityException()
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
使用默认属性初始化类的新实例 SecurityException 。
public:
SecurityException();
public SecurityException();
Public Sub New ()
示例
有关使用 SecurityException 构造函数的示例,请参阅为 SecurityException(String, Object, Object, MethodInfo, Object, IPermission) 构造函数提供的示例。
注解
下表显示了类实例 SecurityException 的初始属性值。
| 财产 | 价值 |
|---|---|
| InnerException | Null 引用(Nothing 在 Visual Basic 中)。 |
| Message | 本地化的错误消息字符串。 |
适用于
SecurityException(String)
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
使用指定的错误消息初始化类的新实例 SecurityException 。
public:
SecurityException(System::String ^ message);
public SecurityException(string message);
public SecurityException(string? message);
new System.Security.SecurityException : string -> System.Security.SecurityException
Public Sub New (message As String)
参数
- message
- String
说明异常原因的错误消息。
示例
有关使用 SecurityException 构造函数的示例,请参阅为 SecurityException(String, Object, Object, MethodInfo, Object, IPermission) 构造函数提供的示例。
注解
下表显示了类实例 SecurityException 的初始属性值。
| 财产 | 价值 |
|---|---|
| InnerException | Null 引用(Nothing 在 Visual Basic 中)。 |
| Message | 本地化的错误消息字符串。 |
适用于
SecurityException(SerializationInfo, StreamingContext)
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
注意
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
使用序列化的数据初始化 SecurityException 类的新实例。
protected:
SecurityException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected SecurityException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected SecurityException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.SecurityException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.SecurityException
new System.Security.SecurityException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.SecurityException
Protected Sub New (info As SerializationInfo, context As StreamingContext)
参数
- info
- SerializationInfo
保存序列化对象数据的对象。
- context
- StreamingContext
有关源或目标的上下文信息。
- 属性
例外
info 是 null。
示例
有关使用 SecurityException 构造函数的示例,请参阅为 SecurityException(String, Object, Object, MethodInfo, Object, IPermission) 构造函数提供的示例。
注解
在反序列化期间调用此构造函数以重新构造通过流传输的异常对象。
此构造函数基于参数中 info 的信息设置以下属性值:
适用于
SecurityException(String, Exception)
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
使用指定的错误消息和对作为此异常原因的内部异常的引用初始化 SecurityException 类的新实例。
public:
SecurityException(System::String ^ message, Exception ^ inner);
public SecurityException(string message, Exception inner);
public SecurityException(string? message, Exception? inner);
new System.Security.SecurityException : string * Exception -> System.Security.SecurityException
Public Sub New (message As String, inner As Exception)
参数
- message
- String
说明异常原因的错误消息。
- inner
- Exception
是当前异常原因的异常。 如果未 innernull 参数,则会在处理内部异常的 catch 块中引发当前异常。
示例
有关使用 SecurityException 构造函数的示例,请参阅为 SecurityException(String, Object, Object, MethodInfo, Object, IPermission) 构造函数提供的示例。
注解
作为上一个异常的直接结果引发的异常应包括对 InnerException 属性中上一个异常的引用。
InnerException 属性返回传入构造函数的相同值,或者如果 null 属性未向构造函数提供内部异常值,则返回 InnerException。
下表显示了类实例 SecurityException 的初始属性值。
| 财产 | 价值 |
|---|---|
| InnerException | 内部异常引用。 |
| Message | 本地化的错误消息字符串。 |
另请参阅
适用于
SecurityException(String, Type)
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
使用指定的错误消息和导致引发异常的权限类型初始化类的新实例 SecurityException 。
public:
SecurityException(System::String ^ message, Type ^ type);
public SecurityException(string? message, Type? type);
public SecurityException(string message, Type type);
new System.Security.SecurityException : string * Type -> System.Security.SecurityException
Public Sub New (message As String, type As Type)
参数
- message
- String
说明异常原因的错误消息。
- type
- Type
导致引发异常的权限的类型。
示例
有关使用 SecurityException 构造函数的示例,请参阅为 SecurityException(String, Object, Object, MethodInfo, Object, IPermission) 构造函数提供的示例。
注解
下表显示了此构造函数设置的属性值。
| 财产 | 价值 |
|---|---|
| Message | 指定的 message本地化错误消息字符串。 |
| PermissionType |
Type失败的权限,由 type. |
适用于
SecurityException(String, Type, String)
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
- Source:
- SecurityException.cs
使用指定的错误消息、导致引发异常的权限类型以及权限状态初始化类的新实例 SecurityException 。
public:
SecurityException(System::String ^ message, Type ^ type, System::String ^ state);
public SecurityException(string? message, Type? type, string? state);
public SecurityException(string message, Type type, string state);
new System.Security.SecurityException : string * Type * string -> System.Security.SecurityException
Public Sub New (message As String, type As Type, state As String)
参数
- message
- String
说明异常原因的错误消息。
- type
- Type
导致引发异常的权限的类型。
- state
- String
导致引发异常的权限的状态。
示例
有关使用 SecurityException 构造函数的示例,请参阅为 SecurityException(String, Object, Object, MethodInfo, Object, IPermission) 构造函数提供的示例。
注解
下表显示了此构造函数设置的属性值。
| 财产 | 价值 |
|---|---|
| Message | 指定的 message本地化错误消息字符串。 |
| PermissionType |
Type失败的权限,由 type. |
| Demanded | 要求的安全权限、权限集或权限集集合失败。 |
适用于
SecurityException(String, Object, Object, MethodInfo, Object, IPermission)
为堆栈上的 Deny 导致的异常初始化类的新实例 SecurityException 。
public:
SecurityException(System::String ^ message, System::Object ^ deny, System::Object ^ permitOnly, System::Reflection::MethodInfo ^ method, System::Object ^ demanded, System::Security::IPermission ^ permThatFailed);
public SecurityException(string message, object deny, object permitOnly, System.Reflection.MethodInfo method, object demanded, System.Security.IPermission permThatFailed);
new System.Security.SecurityException : string * obj * obj * System.Reflection.MethodInfo * obj * System.Security.IPermission -> System.Security.SecurityException
Public Sub New (message As String, deny As Object, permitOnly As Object, method As MethodInfo, demanded As Object, permThatFailed As IPermission)
参数
- message
- String
说明异常原因的错误消息。
- deny
- Object
被拒绝的权限或权限集。
- permitOnly
- Object
仅允许权限或权限集。
- method
- MethodInfo
标识遇到异常的方法的 A MethodInfo 。
- demanded
- Object
所需的权限、权限集或权限集集合。
- permThatFailed
- IPermission
标识失败的权限的一个 IPermission 。
示例
下面的代码示例演示构造 SecurityException(String, Object, Object, MethodInfo, Object, IPermission) 函数的使用。
// Demonstrate the SecurityException constructor
// by throwing the exception again.
Display("Rethrowing the exception thrown as a "
"result of a PermitOnly security action.");
throw gcnew SecurityException(exception->Message,
exception->DenySetInstance,
exception->PermitOnlySetInstance,
exception->Method, exception->Demanded,
exception->FirstPermissionThatFailed);
//Demonstrate the SecurityException constructor by
// throwing the exception again.
Display("Rethrowing the exception thrown as a result of a " +
"PermitOnly security action.");
throw new SecurityException(sE.Message, sE.DenySetInstance,
sE.PermitOnlySetInstance, sE.Method, sE.Demanded,
(IPermission)sE.FirstPermissionThatFailed);
' Demonstrate the SecurityException constructor by
' throwing the exception again.
Display("Rethrowing the exception thrown as a result of a " & _
"PermitOnly security action.")
Throw New SecurityException(sE.Message, sE.DenySetInstance, _
sE.PermitOnlySetInstance, sE.Method, sE.Demanded, _
CType(sE.FirstPermissionThatFailed, IPermission))
注解
如果包含 Deny 的帧导致需求失败,请使用此构造函数。 下表显示了此构造函数设置的属性值。
| 财产 | 价值 |
|---|---|
| Message | 指定的 message本地化错误消息字符串。 |
| FirstPermissionThatFailed | 权限集或权限集集合中指定的 permThatFailed第一个权限。 |
| GrantedSet | 一个空字符串。 |
| Demanded | 由 . 指定的 demanded安全权限、权限集或权限集集合。 |
| RefusedSet | 一个空字符串。 |
| DenySetInstance | 拒绝的安全权限、权限集或权限集集合由 deny. |
| PermitOnlySetInstance | 权限集或权限集集合由 permitOnly. |
| FailedAssemblyInfo |
null。 |
| Method | 指定 MethodInfo 者 method。 |
| Zone | NoZone。 |
| Url | 一个空字符串。 |
适用于
SecurityException(String, AssemblyName, PermissionSet, PermissionSet, MethodInfo, SecurityAction, Object, IPermission, Evidence)
初始化由授予集不足导致的异常的类的新实例 SecurityException 。
public:
SecurityException(System::String ^ message, System::Reflection::AssemblyName ^ assemblyName, System::Security::PermissionSet ^ grant, System::Security::PermissionSet ^ refused, System::Reflection::MethodInfo ^ method, System::Security::Permissions::SecurityAction action, System::Object ^ demanded, System::Security::IPermission ^ permThatFailed, System::Security::Policy::Evidence ^ evidence);
public SecurityException(string message, System.Reflection.AssemblyName assemblyName, System.Security.PermissionSet grant, System.Security.PermissionSet refused, System.Reflection.MethodInfo method, System.Security.Permissions.SecurityAction action, object demanded, System.Security.IPermission permThatFailed, System.Security.Policy.Evidence evidence);
new System.Security.SecurityException : string * System.Reflection.AssemblyName * System.Security.PermissionSet * System.Security.PermissionSet * System.Reflection.MethodInfo * System.Security.Permissions.SecurityAction * obj * System.Security.IPermission * System.Security.Policy.Evidence -> System.Security.SecurityException
Public Sub New (message As String, assemblyName As AssemblyName, grant As PermissionSet, refused As PermissionSet, method As MethodInfo, action As SecurityAction, demanded As Object, permThatFailed As IPermission, evidence As Evidence)
参数
- message
- String
说明异常原因的错误消息。
- assemblyName
- AssemblyName
一个 AssemblyName 指定导致异常的程序集的名称。
- grant
- PermissionSet
一个 PermissionSet 表示授予程序集的权限。
- refused
- PermissionSet
表示拒绝的权限或权限集的 A PermissionSet 。
- method
- MethodInfo
一个 MethodInfo 表示遇到异常的方法。
- action
- SecurityAction
其中一个 SecurityAction 值。
- demanded
- Object
所需的权限、权限集或权限集集合。
- permThatFailed
- IPermission
表示失败的权限的一个 IPermission 。
注解
当授权集导致需求失败时,使用此构造函数引发异常。
下表显示了此构造函数设置的属性值。
| 财产 | 价值 |
|---|---|
| Message | 指定的 message本地化错误消息字符串。 |
| FirstPermissionThatFailed | 权限集或权限集集合中指定的 permThatFailed第一个权限。 |
| GrantedSet | 指定 PermissionSet 者 grant。 |
| Demanded | 所指定的 demanded安全权限、权限集或权限集集合失败。 |
| RefusedSet | 指定 PermissionSet 者 refused。 |
| DenySetInstance | 一个空字符串。 |
| PermitOnlySetInstance | 一个空字符串。 |
| FailedAssemblyInfo | 指定 AssemblyName 者 assemblyName。 |
| Method | 指定 MethodInfo 者 method。 |
| Zone |
SecurityZone指定的evidence值Evidence。 |
| Url | 指定的 evidenceURLEvidence。 |