XmlException Konstruktorer

Definition

Initierar en ny instans av XmlException klassen.

Överlagringar

Name Description
XmlException()

Initierar en ny instans av XmlException klassen.

XmlException(String)

Initierar en ny instans av XmlException klassen med ett angivet felmeddelande.

XmlException(SerializationInfo, StreamingContext)
Föråldrad.

Initierar en ny instans av klassen med hjälp av XmlException informationen i objekten SerializationInfo och StreamingContext .

XmlException(String, Exception)

Initierar en ny instans av XmlException klassen.

XmlException(String, Exception, Int32, Int32)

Initierar en ny instans av XmlException klassen med det angivna meddelandet, det inre undantaget, radnumret och radpositionen.

XmlException()

Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs

Initierar en ny instans av XmlException klassen.

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

Kommentarer

XmlException är ett allmänt XML-relaterat fel som utlöses om problem uppstår under XML-bearbetningen. I följande exempel genereras ett XML-undantag eftersom <sluttaggen för kontakter> är felstavad:

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);
}
Try
    Dim contacts As XElement = XElement.Parse(
        "<Contacts>  
            <Contact>  
                <Name>Jim Wilson</Name>  
            </Contact>  
         </Contcts>")
    Console.WriteLine(contacts)
Catch e As System.Xml.XmlException
    Console.WriteLine(e.Message)
End Try

Gäller för

XmlException(String)

Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs

Initierar en ny instans av XmlException klassen med ett angivet felmeddelande.

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

Parametrar

message
String

Felbeskrivningen.

Gäller för

XmlException(SerializationInfo, StreamingContext)

Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs

Varning

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

Initierar en ny instans av klassen med hjälp av XmlException informationen i objekten SerializationInfo och StreamingContext .

protected:
 XmlException(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 XmlException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected XmlException(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}")>]
new System.Xml.XmlException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Xml.XmlException
new System.Xml.XmlException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Xml.XmlException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parametrar

info
SerializationInfo

Objektet SerializationInfo som innehåller alla egenskaper för en XmlException.

context
StreamingContext

Objektet StreamingContext som innehåller kontextinformationen.

Attribut

Gäller för

XmlException(String, Exception)

Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs

Initierar en ny instans av XmlException klassen.

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

Parametrar

message
String

Beskrivningen av felvillkoret.

innerException
Exception

Den Exception som kastade XmlException, om någon. Det här värdet kan vara null.

Gäller för

XmlException(String, Exception, Int32, Int32)

Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs
Källa:
XmlException.cs

Initierar en ny instans av XmlException klassen med det angivna meddelandet, det inre undantaget, radnumret och radpositionen.

public:
 XmlException(System::String ^ message, Exception ^ innerException, int lineNumber, int linePosition);
public XmlException(string message, Exception innerException, int lineNumber, int linePosition);
public XmlException(string? message, Exception? innerException, int lineNumber, int linePosition);
new System.Xml.XmlException : string * Exception * int * int -> System.Xml.XmlException
Public Sub New (message As String, innerException As Exception, lineNumber As Integer, linePosition As Integer)

Parametrar

message
String

Felbeskrivningen.

innerException
Exception

Undantaget som är orsaken till det aktuella undantaget. Det här värdet kan vara null.

lineNumber
Int32

Radnumret som anger var felet inträffade.

linePosition
Int32

Radpositionen som anger var felet inträffade.

Gäller för