Lue englanniksi Muokkaa

Jaa


XmlException Constructors

Definition

Initializes a new instance of the XmlException class.

Overloads

XmlException()

Initializes a new instance of the XmlException class.

XmlException(String)

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

XmlException(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the XmlException class using the information in the SerializationInfo and StreamingContext objects.

XmlException(String, Exception)

Initializes a new instance of the XmlException class.

XmlException(String, Exception, Int32, Int32)

Initializes a new instance of the XmlException class with the specified message, inner exception, line number, and line position.

XmlException()

Source:
XmlException.cs
Source:
XmlException.cs
Source:
XmlException.cs

Initializes a new instance of the XmlException class.

C#
public XmlException();

Remarks

The XmlException is a generic XML-related error that is thrown if problems occur during XML processing. The following example throws an XML exception because the <contacts> end tag is misspelled:

C#
using System;
using System.Xml.Linq;

try
{
    XElement contacts = XElement.Parse(
        @"<Contacts>
            <Contact>
                <Name>Jim Wilson</Name>
            </Contact>
          </Contcts>");
    Console.WriteLine(contacts);
}
catch (System.Xml.XmlException e)
{
    Console.WriteLine(e.Message);
}

Applies to

.NET 10 ja muut versiot
Tuote Versiot
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.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 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

XmlException(String)

Source:
XmlException.cs
Source:
XmlException.cs
Source:
XmlException.cs

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

C#
public XmlException(string message);
C#
public XmlException(string? message);

Parameters

message
String

The error description.

Applies to

.NET 10 ja muut versiot
Tuote Versiot
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.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 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

XmlException(SerializationInfo, StreamingContext)

Source:
XmlException.cs
Source:
XmlException.cs
Source:
XmlException.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 XmlException class using the information in the SerializationInfo and StreamingContext objects.

C#
[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 XmlException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
C#
protected XmlException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);

Parameters

info
SerializationInfo

The SerializationInfo object containing all the properties of an XmlException.

context
StreamingContext

The StreamingContext object containing the context information.

Attributes

Applies to

.NET 10 ja muut versiot
Tuote Versiot (Vanhentunut)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 (8, 9, 10)
.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, 2.1

XmlException(String, Exception)

Source:
XmlException.cs
Source:
XmlException.cs
Source:
XmlException.cs

Initializes a new instance of the XmlException class.

C#
public XmlException(string message, Exception innerException);
C#
public XmlException(string? message, Exception? innerException);

Parameters

message
String

The description of the error condition.

innerException
Exception

The Exception that threw the XmlException, if any. This value can be null.

Applies to

.NET 10 ja muut versiot
Tuote Versiot
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.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 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

XmlException(String, Exception, Int32, Int32)

Source:
XmlException.cs
Source:
XmlException.cs
Source:
XmlException.cs

Initializes a new instance of the XmlException class with the specified message, inner exception, line number, and line position.

C#
public XmlException(string message, Exception innerException, int lineNumber, int linePosition);
C#
public XmlException(string? message, Exception? innerException, int lineNumber, int linePosition);

Parameters

message
String

The error description.

innerException
Exception

The exception that is the cause of the current exception. This value can be null.

lineNumber
Int32

The line number indicating where the error occurred.

linePosition
Int32

The line position indicating where the error occurred.

Applies to

.NET 10 ja muut versiot
Tuote Versiot
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.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 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0