แก้ไข

แชร์ผ่าน


ValidationException Constructors

Definition

Initializes a new instance of the ValidationException class.

Overloads

ValidationException()

Initializes a new instance of the ValidationException class using an error message generated by the system.

ValidationException(String)

Initializes a new instance of the ValidationException class using a specified error message.

ValidationException(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the ValidationException class using serialized data.

ValidationException(String, Exception)

Initializes a new instance of the ValidationException class using a specified error message and a collection of inner exception instances.

ValidationException(ValidationResult, ValidationAttribute, Object)

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)

Initializes a new instance of the ValidationException class using a specified error message, a validation attribute, and the value of the current exception.

ValidationException()

Source:
ValidationException.cs
Source:
ValidationException.cs
Source:
ValidationException.cs

Initializes a new instance of the ValidationException class using an error message generated by the system.

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

Remarks

This method is the parameterless constructor for the ValidationException class.

Applies to

ValidationException(String)

Source:
ValidationException.cs
Source:
ValidationException.cs
Source:
ValidationException.cs

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)

Parameters

message
String

A specified message that states the error.

Remarks

For more information about how to use this constructor, see How to: Customize Data Field Validation in the Data Model.

Applies to

ValidationException(SerializationInfo, StreamingContext)

Source:
ValidationException.cs
Source:
ValidationException.cs
Source:
ValidationException.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

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);
[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 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
[<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.ComponentModel.DataAnnotations.ValidationException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.ComponentModel.DataAnnotations.ValidationException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameters

info
SerializationInfo

The object that holds the serialized data.

context
StreamingContext

Context information about the source or destination of the serialized object.

Attributes

Remarks

This constructor is called during deserialization to reconstitute the exception object that is transmitted over a stream.

Applies to

ValidationException(String, Exception)

Source:
ValidationException.cs
Source:
ValidationException.cs
Source:
ValidationException.cs

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)

Parameters

message
String

The error message.

innerException
Exception

The collection of validation exceptions.

Remarks

You typically will not use this constructor because validation exceptions are stored in the InnerExceptions property, not innerException.

Applies to

ValidationException(ValidationResult, ValidationAttribute, Object)

Source:
ValidationException.cs
Source:
ValidationException.cs
Source:
ValidationException.cs

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)

Parameters

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.

Applies to

ValidationException(String, ValidationAttribute, Object)

Source:
ValidationException.cs
Source:
ValidationException.cs
Source:
ValidationException.cs

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)

Parameters

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.

Remarks

For more information, see How to: Customize Data Field Validation in the Data Model.

Applies to