XmlException 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 XmlException 类的新实例。
重载
| 名称 | 说明 |
|---|---|
| XmlException() |
初始化 |
| XmlException(String) |
使用指定的错误消息初始化类的新实例 |
| XmlException(SerializationInfo, StreamingContext) |
已过时.
使用对象中 |
| XmlException(String, Exception) |
初始化 |
| XmlException(String, Exception, Int32, Int32) |
使用指定的消息、内部异常、行号和行位置初始化类的新实例 |
XmlException()
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
初始化 XmlException 类的新实例。
public:
XmlException();
public XmlException();
Public Sub New ()
注解
XmlException这是一个与 XML 相关的泛型错误,如果在 XML 处理过程中出现问题,则会引发此错误。 以下示例引发 XML 异常,因为 <联系人> 结束标记拼写错误:
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
适用于
XmlException(String)
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
使用指定的错误消息初始化类的新实例 XmlException 。
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)
参数
- message
- String
错误说明。
适用于
XmlException(SerializationInfo, StreamingContext)
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
注意
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
使用对象中XmlExceptionSerializationInfo的信息初始化类的新实例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)
参数
- info
- SerializationInfo
SerializationInfo包含 .XmlException. 的所有属性的对象
- context
- StreamingContext
StreamingContext包含上下文信息的对象。
- 属性
适用于
XmlException(String, Exception)
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
初始化 XmlException 类的新实例。
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)
参数
- message
- String
错误条件的说明。
适用于
XmlException(String, Exception, Int32, Int32)
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
- Source:
- XmlException.cs
使用指定的消息、内部异常、行号和行位置初始化类的新实例 XmlException 。
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)
参数
- message
- String
错误说明。
- innerException
- Exception
是当前异常原因的异常。 此值可为 null。
- lineNumber
- Int32
指示发生错误的行号。
- linePosition
- Int32
指示发生错误的行位置。