AggregateException Constructors

Definition

Initializes a new instance of the AggregateException class.

Overloads

AggregateException()

Initializes a new instance of the AggregateException class with a system-supplied message that describes the error.

AggregateException(IEnumerable<Exception>)

Initializes a new instance of the AggregateException class with references to the inner exceptions that are the cause of this exception.

AggregateException(Exception[])

Initializes a new instance of the AggregateException class with references to the inner exceptions that are the cause of this exception.

AggregateException(String)

Initializes a new instance of the AggregateException class with a specified message that describes the error.

AggregateException(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the AggregateException class with serialized data.

AggregateException(String, IEnumerable<Exception>)

Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.

AggregateException(String, Exception)

Initializes a new instance of the AggregateException class with a specified error message and a reference to the inner exception that is the cause of this exception.

AggregateException(String, Exception[])

Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.

AggregateException()

Initializes a new instance of the AggregateException class with a system-supplied message that describes the error.

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

Remarks

This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "System.AggregateException: One or more errors occurred." This message takes into account the current system culture.

The following table shows the initial property values for an instance of AggregateException.

Property Value
InnerException null.
Message The localized error message string.

See also

Applies to

AggregateException(IEnumerable<Exception>)

Initializes a new instance of the AggregateException class with references to the inner exceptions that are the cause of this exception.

public:
 AggregateException(System::Collections::Generic::IEnumerable<Exception ^> ^ innerExceptions);
public AggregateException (System.Collections.Generic.IEnumerable<Exception> innerExceptions);
new AggregateException : seq<Exception> -> AggregateException
Public Sub New (innerExceptions As IEnumerable(Of Exception))

Parameters

innerExceptions
IEnumerable<Exception>

The exceptions that are the cause of the current exception.

Exceptions

The innerExceptions argument is null.

An element of innerExceptions is null.

Applies to

AggregateException(Exception[])

Initializes a new instance of the AggregateException class with references to the inner exceptions that are the cause of this exception.

public:
 AggregateException(... cli::array <Exception ^> ^ innerExceptions);
public AggregateException (params Exception[] innerExceptions);
new AggregateException : Exception[] -> AggregateException
Public Sub New (ParamArray innerExceptions As Exception())

Parameters

innerExceptions
Exception[]

The exceptions that are the cause of the current exception.

Exceptions

The innerExceptions argument is null.

An element of innerExceptions is null.

Applies to

AggregateException(String)

Initializes a new instance of the AggregateException class with a specified message that describes the error.

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

Parameters

message
String

The message that describes the exception. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

Remarks

The following table shows the initial property values for an instance of AggregateException.

Property Value
InnerException null.
Message The error message string specified in message.

See also

Applies to

AggregateException(SerializationInfo, StreamingContext)

Caution

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

Initializes a new instance of the AggregateException class with serialized data.

protected:
 AggregateException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected AggregateException (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 AggregateException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Security.SecurityCritical]
protected AggregateException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new AggregateException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> AggregateException
[<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 AggregateException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> AggregateException
[<System.Security.SecurityCritical>]
new AggregateException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> AggregateException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameters

info
SerializationInfo

The object that holds the serialized object data.

context
StreamingContext

The contextual information about the source or destination.

Attributes

Exceptions

The info argument is null.

The exception could not be deserialized correctly.

Remarks

This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. For more information, see XML and SOAP Serialization.

See also

Applies to

AggregateException(String, IEnumerable<Exception>)

Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.

public:
 AggregateException(System::String ^ message, System::Collections::Generic::IEnumerable<Exception ^> ^ innerExceptions);
public AggregateException (string message, System.Collections.Generic.IEnumerable<Exception> innerExceptions);
public AggregateException (string? message, System.Collections.Generic.IEnumerable<Exception> innerExceptions);
new AggregateException : string * seq<Exception> -> AggregateException
Public Sub New (message As String, innerExceptions As IEnumerable(Of Exception))

Parameters

message
String

The error message that explains the reason for the exception.

innerExceptions
IEnumerable<Exception>

The exceptions that are the cause of the current exception.

Exceptions

The innerExceptions argument is null.

An element of innerExceptions is null.

Applies to

AggregateException(String, Exception)

Initializes a new instance of the AggregateException class with a specified error message and a reference to the inner exception that is the cause of this exception.

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

Parameters

message
String

The message that describes the exception. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

innerException
Exception

The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

Exceptions

The innerException argument is null.

Remarks

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. The InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

The following table shows the initial property values for an instance of AggregateException.

Property Value
InnerException null.
Message The error message string specified in message.

See also

Applies to

AggregateException(String, Exception[])

Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.

public:
 AggregateException(System::String ^ message, ... cli::array <Exception ^> ^ innerExceptions);
public AggregateException (string message, params Exception[] innerExceptions);
public AggregateException (string? message, params Exception[] innerExceptions);
new AggregateException : string * Exception[] -> AggregateException
Public Sub New (message As String, ParamArray innerExceptions As Exception())

Parameters

message
String

The error message that explains the reason for the exception.

innerExceptions
Exception[]

The exceptions that are the cause of the current exception.

Exceptions

The innerExceptions argument is null.

An element of innerExceptions is null.

Applies to