XmlSyntaxException Constructors

Definition

Initializes a new instance of the XmlSyntaxException class.

Overloads

XmlSyntaxException()

Initializes a new instance of the XmlSyntaxException class with default properties.

XmlSyntaxException(Int32)

Initializes a new instance of the XmlSyntaxException class with the line number where the exception was detected.

XmlSyntaxException(String)

Initializes a new instance of the XmlSyntaxException class with a specified error message.

XmlSyntaxException(Int32, String)

Initializes a new instance of the XmlSyntaxException class with a specified error message and the line number where the exception was detected.

XmlSyntaxException(String, Exception)

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

XmlSyntaxException()

Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs

Initializes a new instance of the XmlSyntaxException class with default properties.

C#
public XmlSyntaxException();

Remarks

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

Property Value
InnerException null.
Message "Invalid syntax."

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

XmlSyntaxException(Int32)

Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs

Initializes a new instance of the XmlSyntaxException class with the line number where the exception was detected.

C#
public XmlSyntaxException(int lineNumber);

Parameters

lineNumber
Int32

The line number of the XML stream where the XML syntax error was detected.

Remarks

The line number of an XML stream is updated whenever a newline character is detected. Numbering begins with 1 for the first line.

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

Property Value
InnerException null.
Message "Invalid syntax on line lineNumber."

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

XmlSyntaxException(String)

Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs

Initializes a new instance of the XmlSyntaxException class with a specified error message.

C#
public XmlSyntaxException(string message);

Parameters

message
String

The error message that explains the reason for the exception.

Remarks

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

Property Value
InnerException null.
Message The error message string.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

XmlSyntaxException(Int32, String)

Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs

Initializes a new instance of the XmlSyntaxException class with a specified error message and the line number where the exception was detected.

C#
public XmlSyntaxException(int lineNumber, string message);

Parameters

lineNumber
Int32

The line number of the XML stream where the XML syntax error was detected.

message
String

The error message that explains the reason for the exception.

Remarks

The line number of an XML stream is updated whenever a newline character is detected. Numbering begins with 1 for the first line.

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

Property Value
InnerException null.
Message "Invalid syntax on line lineNumber - message "

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

XmlSyntaxException(String, Exception)

Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs
Source:
XmlSyntaxException.cs

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

C#
public XmlSyntaxException(string message, Exception inner);

Parameters

message
String

The error message that explains the reason for the exception.

inner
Exception

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

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 XmlSyntaxException.

Property Value
InnerException The inner exception reference.
Message The error message string.

See also

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10