ValidationException 构造函数
定义
初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class.
重载
| ValidationException() |
使用系统生成的错误消息初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using an error message generated by the system. |
| ValidationException(String) |
使用指定的错误消息初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using a specified error message. |
| ValidationException(SerializationInfo, StreamingContext) |
使用序列化数据初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using serialized data. |
| ValidationException(String, Exception) |
使用指定的错误消息和内部异常实例的集合初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using a specified error message and a collection of inner exception instances. |
| ValidationException(ValidationResult, ValidationAttribute, Object) |
使用验证结果、验证特性以及当前异常的值初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class by using a validation result, a validation attribute, and the value of the current exception. |
| ValidationException(String, ValidationAttribute, Object) |
使用指定的错误消息、验证特性以及当前异常的值初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using a specified error message, a validation attribute, and the value of the current exception. |
ValidationException()
使用系统生成的错误消息初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using an error message generated by the system.
public:
ValidationException();
public ValidationException ();
Public Sub New ()
注解
此方法是类的无参数构造函数 ValidationException 。This method is the parameterless constructor for the ValidationException class.
适用于
ValidationException(String)
使用指定的错误消息初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using a specified error message.
public:
ValidationException(System::String ^ message);
public ValidationException (string message);
public ValidationException (string? message);
new System.ComponentModel.DataAnnotations.ValidationException : string -> System.ComponentModel.DataAnnotations.ValidationException
Public Sub New (message As String)
参数
- message
- String
一条说明错误的指定消息。A specified message that states the error.
注解
有关如何使用此构造函数的详细信息,请参阅 如何:自定义数据模型中的数据字段验证。For more information about how to use this constructor, see How to: Customize Data Field Validation in the Data Model.
适用于
ValidationException(SerializationInfo, StreamingContext)
使用序列化数据初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using serialized data.
protected:
ValidationException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ValidationException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.ComponentModel.DataAnnotations.ValidationException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.ComponentModel.DataAnnotations.ValidationException
Protected Sub New (info As SerializationInfo, context As StreamingContext)
参数
- info
- SerializationInfo
包含序列化数据的对象。The object that holds the serialized data.
- context
- StreamingContext
有关序列化对象的源或目标的上下文信息。Context information about the source or destination of the serialized object.
注解
在反序列化过程中调用此构造函数来重建通过流传输的异常对象。This constructor is called during deserialization to reconstitute the exception object that is transmitted over a stream.
适用于
ValidationException(String, Exception)
使用指定的错误消息和内部异常实例的集合初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using a specified error message and a collection of inner exception instances.
public:
ValidationException(System::String ^ message, Exception ^ innerException);
public ValidationException (string message, Exception innerException);
public ValidationException (string? message, Exception? innerException);
new System.ComponentModel.DataAnnotations.ValidationException : string * Exception -> System.ComponentModel.DataAnnotations.ValidationException
Public Sub New (message As String, innerException As Exception)
参数
- message
- String
错误消息。The error message.
- innerException
- Exception
验证异常的集合。The collection of validation exceptions.
注解
通常不会使用此构造函数,因为验证异常存储在 InnerExceptions 属性中,而不是 innerException 。You typically will not use this constructor because validation exceptions are stored in the InnerExceptions property, not innerException.
适用于
ValidationException(ValidationResult, ValidationAttribute, Object)
使用验证结果、验证特性以及当前异常的值初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class by using a validation result, a validation attribute, and the value of the current exception.
public:
ValidationException(System::ComponentModel::DataAnnotations::ValidationResult ^ validationResult, System::ComponentModel::DataAnnotations::ValidationAttribute ^ validatingAttribute, System::Object ^ value);
public ValidationException (System.ComponentModel.DataAnnotations.ValidationResult validationResult, System.ComponentModel.DataAnnotations.ValidationAttribute validatingAttribute, object value);
public ValidationException (System.ComponentModel.DataAnnotations.ValidationResult validationResult, System.ComponentModel.DataAnnotations.ValidationAttribute? validatingAttribute, object? value);
new System.ComponentModel.DataAnnotations.ValidationException : System.ComponentModel.DataAnnotations.ValidationResult * System.ComponentModel.DataAnnotations.ValidationAttribute * obj -> System.ComponentModel.DataAnnotations.ValidationException
Public Sub New (validationResult As ValidationResult, validatingAttribute As ValidationAttribute, value As Object)
参数
- validationResult
- ValidationResult
验证结果的列表。The list of validation results.
- validatingAttribute
- ValidationAttribute
引发当前异常的特性。The attribute that caused the current exception.
- value
- Object
导致特性触发验证错误的对象的值。The value of the object that caused the attribute to trigger the validation error.
适用于
ValidationException(String, ValidationAttribute, Object)
使用指定的错误消息、验证特性以及当前异常的值初始化 ValidationException 类的新实例。Initializes a new instance of the ValidationException class using a specified error message, a validation attribute, and the value of the current exception.
public:
ValidationException(System::String ^ errorMessage, System::ComponentModel::DataAnnotations::ValidationAttribute ^ validatingAttribute, System::Object ^ value);
public ValidationException (string errorMessage, System.ComponentModel.DataAnnotations.ValidationAttribute validatingAttribute, object value);
public ValidationException (string? errorMessage, System.ComponentModel.DataAnnotations.ValidationAttribute? validatingAttribute, object? value);
new System.ComponentModel.DataAnnotations.ValidationException : string * System.ComponentModel.DataAnnotations.ValidationAttribute * obj -> System.ComponentModel.DataAnnotations.ValidationException
Public Sub New (errorMessage As String, validatingAttribute As ValidationAttribute, value As Object)
参数
- errorMessage
- String
说明错误的消息。The message that states the error.
- validatingAttribute
- ValidationAttribute
引发当前异常的特性。The attribute that caused the current exception.
- value
- Object
使特性引起验证错误的对象的值。The value of the object that caused the attribute to trigger validation error.
注解
有关详细信息,请参阅如何:自定义数据模型中的数据字段验证。For more information, see How to: Customize Data Field Validation in the Data Model.