UnauthorizedAccessException 构造函数

定义

初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class.

重载

UnauthorizedAccessException()

初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class.

UnauthorizedAccessException(String)

用指定的错误消息初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class with a specified error message.

UnauthorizedAccessException(SerializationInfo, StreamingContext)

用序列化数据初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class with serialized data.

UnauthorizedAccessException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class with a specified error message and a reference to the inner exception that is the cause of this exception.

UnauthorizedAccessException()

初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class.

public:
 UnauthorizedAccessException();
public UnauthorizedAccessException ();
Public Sub New ()

注解

此构造函数将 Message 新实例的属性初始化为系统提供的描述错误的消息,如 "尝试执行未经授权的操作"。This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "Attempted to perform an unauthorized operation." 此消息会考虑当前系统区域性。This message takes into account the current system culture.

下表显示了 MemberAccessException 实例的初始属性值。The following table shows the initial property values for an instance of MemberAccessException.

propertiesProperty Value
InnerException 空引用(在 Visual Basic 中为 Nothing)。A null reference (Nothing in Visual Basic).
Message 本地化的错误消息字符串。The localized error message string.

适用于

产品 已引入

UnauthorizedAccessException(String)

用指定的错误消息初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class with a specified error message.

public:
 UnauthorizedAccessException(System::String ^ message);
public UnauthorizedAccessException (string message);
new UnauthorizedAccessException : string -> UnauthorizedAccessException
Public Sub New (message As String)

参数

message
String

描述错误的消息。The message that describes the error.

注解

参数的内容 message 应为用户所理解。The content of the message parameter should be understandable to the user. 此构造函数的调用方需要确保此字符串已针对当前系统区域性进行了本地化。The caller of this constructor is required to ensure that this string has been localized for the current system culture.

下表显示了 UnauthorizedAccessException 实例的初始属性值。The following table shows the initial property values for an instance of UnauthorizedAccessException.

propertiesProperty Value
InnerException 空引用(在 Visual Basic 中为 Nothing)。A null reference (Nothing in Visual Basic).
Message 错误消息字符串。The error message string.

适用于

产品 已引入

UnauthorizedAccessException(SerializationInfo, StreamingContext)

用序列化数据初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class with serialized data.

protected:
 UnauthorizedAccessException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected UnauthorizedAccessException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new UnauthorizedAccessException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> UnauthorizedAccessException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo

包含有关所引发异常的序列化对象数据的 SerializationInfoThe SerializationInfo that holds the serialized object data about the exception being thrown.

context
StreamingContext

StreamingContext,它包含关于源或目标的上下文信息。The StreamingContext that contains contextual information about the source or destination.

适用于

产品 已引入

UnauthorizedAccessException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 UnauthorizedAccessException 类的新实例。Initializes a new instance of the UnauthorizedAccessException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public:
 UnauthorizedAccessException(System::String ^ message, Exception ^ inner);
public UnauthorizedAccessException (string message, Exception inner);
new UnauthorizedAccessException : string * Exception -> UnauthorizedAccessException
Public Sub New (message As String, inner As Exception)

参数

message
String

解释异常原因的错误消息。The error message that explains the reason for the exception.

inner
Exception

导致当前异常的异常。The exception that is the cause of the current exception. 如果 inner 参数不是 null 引用(在 Visual Basic 中为 Nothing),则在处理内部异常的 catch 块中引发当前异常。If the inner parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.

注解

因前一个异常而直接引发的异常应在 InnerException 属性中包含对前一个异常的引用。An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. InnerException 属性返回传递到构造函数中的相同值,或者如果 Nothing 属性不向构造函数提供内部异常值,则为空引用(在 Visual Basic 中为 InnerException)。The InnerException property returns the same value that is passed into the constructor, or a null reference (Nothing in Visual Basic) if the InnerException property does not supply the inner exception value to the constructor.

下表显示了 UnauthorizedAccessException 实例的初始属性值。The following table shows the initial property values for an instance of UnauthorizedAccessException.

propertiesProperty “值”Value
InnerException 内部异常引用。The inner exception reference.
Message 错误消息字符串。The error message string.

适用于

产品 已引入