XamlParseException XamlParseException XamlParseException XamlParseException Class

定义

表示来自 WPF 分析器的、特定于分析器的异常的异常类。Represents the exception class for parser-specific exceptions from a WPF XAML parser. 此异常用于 .NET Framework 3.0 和 .NET Framework 3.5 中的 XAML API 或 WPF XAML 分析器操作,或者通过调用 XamlReader API 而特别用于 WPF XAML 分析器。This exception is used in XAML API or WPF XAML parser operations from .NET Framework 3.0 and .NET Framework 3.5, or for specific use of the WPF XAML parser by calling XamlReader API.

public ref class XamlParseException : SystemException
[System.Serializable]
public class XamlParseException : SystemException
type XamlParseException = class
    inherit SystemException
Public Class XamlParseException
Inherits SystemException
继承
属性

注解

XamlParseException仅用于 WPF 实现的 XAML 分析器, 该分析器对 WPF 应用程序执行 XAML 分析和加载。XamlParseException is used only for the WPF-implemented XAML parser that performs the XAML parsing and loading for WPF applications. 具体而言, 例外仅适用于应用程序的目标.NET Framework 3.0.NET Framework 3.0.NET Framework 3.5.NET Framework 3.5Specifically, the exception is only relevant when an application targets .NET Framework 3.0.NET Framework 3.0 and .NET Framework 3.5.NET Framework 3.5. 异常还可能源自用户代码, 即对连接 WPF 实现的 XAML 分析器的 Api 的运行时调用, 以便从正在运行的 WPF 应用程序 (例如, 调用XamlReader.Load) 中加载 XAML。The exception can also originate from user code in run-time calls to APIs that hook up the WPF-implemented XAML parser to load XAML from within a running WPF application (for example, calls to XamlReader.Load).

对于.NET Framework 4.NET Framework 4,通常报告XAMLSystem.Xaml处理异常的异常在不同的命名空间()和不同的程序集(system.exception)中定义。XamlParseExceptionFor .NET Framework 4.NET Framework 4, the XamlParseException exception that typically reports XAML processing exceptions is defined in a different namespace (System.Xaml) and a different assembly (System.Xaml).

除非您正在编写等效于 WPF XAML 分析器或.NET Framework 3.0.NET Framework 3.0使用和.NET Framework 3.5.NET Framework 3.5目标, 否则通常不会从自己的代码XamlParseException中引发。Unless you are writing an equivalent to the WPF XAML parser or working with .NET Framework 3.0.NET Framework 3.0 and .NET Framework 3.5.NET Framework 3.5 targeting, you generally will not throw XamlParseException from your own code. 但是, 有时需要处理异常。However, handling for the exception is sometimes necessary. 对于应用程序方案, 可能需要取消 XAML 分析错误, 应用程序级别DispatcherUnhandledException事件处理程序是处理运行时XamlParseException的一种方法。For application scenarios, where you may want to suppress XAML parse errors, a Dispatcher UnhandledException event handler at the application level is one way to handle a run-time XamlParseException. 是否取消异常或让它们看起来用户代码取决于你为加载 XAML 而设计应用程序的方式, 以及分配给应用程序所加载的 XAML 的信任级别。Whether to suppress exceptions or let them surface to user code depends on how you design your application for purposes of loading XAML, and the trust level that you assign to the XAML your application loads. 有关详细信息, 请参阅 xaml概述 (WPF)中的xaml 安全注意事项或 "xaml 安全性" 部分。For more information, see XAML Security Considerations or "XAML Security" section of XAML Overview (WPF).

对于应用程序的页, 当引发XamlParseException时, 它通常位于页面类发出的InitializeComponent调用的上下文中, 这是 wpf 应用程序模型在每页级别的 wpf XAML 分析器的使用入口点。For pages of an application, when the XamlParseException is thrown, it is usually in the context of the InitializeComponent call made by your page class, which is the entry point for the WPF application model's usage of the WPF XAML parser at the per-page level. 因此, 另一个可能的处理策略try/catch是将InitializeComponent块放置在中。Therefore another possible handling strategy is to place try/catch blocks in InitializeComponent. 但是, 这种方法并不能很好地与模板、可视化设计图面以及挂钩InitializeComponent的其他生成的源集成。However, this technique does not integrate well with templates, visual design surfaces and other generated sources that hook up InitializeComponent.

构造函数

XamlParseException() XamlParseException() XamlParseException() XamlParseException()

初始化 XamlParseException 类的新实例。Initializes a new instance of the XamlParseException class.

XamlParseException(SerializationInfo, StreamingContext) XamlParseException(SerializationInfo, StreamingContext) XamlParseException(SerializationInfo, StreamingContext) XamlParseException(SerializationInfo, StreamingContext)

初始化 XamlParseException 类的新实例。Initializes a new instance of the XamlParseException class.

XamlParseException(String) XamlParseException(String) XamlParseException(String) XamlParseException(String)

使用指定的异常消息字符串初始化 XamlParseException 类的新实例。Initializes a new instance of the XamlParseException class, using the specified exception message string.

XamlParseException(String, Exception) XamlParseException(String, Exception) XamlParseException(String, Exception) XamlParseException(String, Exception)

使用指定的异常消息字符串和内部异常初始化 XamlParseException 类的新实例。Initializes a new instance of the XamlParseException class, using the specified exception message string and inner exception.

XamlParseException(String, Int32, Int32) XamlParseException(String, Int32, Int32) XamlParseException(String, Int32, Int32) XamlParseException(String, Int32, Int32)

使用指定的异常消息字符串、指定的行号以及行中的位置初始化 XamlParseException 类的新实例。Initializes a new instance of the XamlParseException class, using the specified exception message string, and the specified line number and position in the line.

XamlParseException(String, Int32, Int32, Exception) XamlParseException(String, Int32, Int32, Exception) XamlParseException(String, Int32, Int32, Exception) XamlParseException(String, Int32, Int32, Exception)

使用指定的异常消息、内部异常、行号以及行中的位置初始化 XamlParseException 类的新实例。Initializes a new instance of the XamlParseException class, using the specified exception message, inner exception, line number, and position in the line.

属性

BaseUri BaseUri BaseUri BaseUri

引发异常时获取基 URI 信息。Gets base URI information when the exception is thrown.

Data Data Data Data

获取提供有关异常的其他用户定义信息的键/值对集合。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(Inherited from Exception)
HelpLink HelpLink HelpLink HelpLink

获取或设置指向与此异常关联的帮助文件链接。Gets or sets a link to the help file associated with this exception.

(Inherited from Exception)
HResult HResult HResult HResult

获取或设置 HRESULT(一个分配给特定异常的编码数字值)。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(Inherited from Exception)
InnerException InnerException InnerException InnerException

获取导致当前异常的 Exception 实例。Gets the Exception instance that caused the current exception.

(Inherited from Exception)
KeyContext KeyContext KeyContext KeyContext

获取或设置字典中发生异常的项的键值。Gets or sets the key value of the item in a dictionary where the exception occurred.

LineNumber LineNumber LineNumber LineNumber

获取发生异常的行号。Gets the line number where the exception occurred.

LinePosition LinePosition LinePosition LinePosition

获取行中发生异常的位置。Gets the position in the line where the exception occurred.

Message Message Message Message

获取描述当前异常的消息。Gets a message that describes the current exception.

(Inherited from Exception)
NameContext NameContext NameContext NameContext

获取或设置发生异常的对象的 XAML 名称。Gets or sets the XAML name of the object where the exception occurred.

Source Source Source Source

获取或设置导致错误的应用程序或对象的名称。Gets or sets the name of the application or the object that causes the error.

(Inherited from Exception)
StackTrace StackTrace StackTrace StackTrace

获取调用堆栈上的即时框架字符串表示形式。Gets a string representation of the immediate frames on the call stack.

(Inherited from Exception)
TargetSite TargetSite TargetSite TargetSite

获取引发当前异常的方法。Gets the method that throws the current exception.

(Inherited from Exception)
UidContext UidContext UidContext UidContext

获取或设置发生异常的对象的 x:Uid DirectiveGets or sets the x:Uid Directive of the object where the exception occurred.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetBaseException() GetBaseException() GetBaseException() GetBaseException()

当在派生类中重写时,返回 Exception,它是一个或多个并发的异常的根源。When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(Inherited from Exception)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

通过填充指定的 SerializationInfo 对象,获取序列化指定对象所需的数据。Gets the data that is required to serialize the specified object by populating the specified SerializationInfo object.

GetType() GetType() GetType() GetType()

获取当前实例的运行时类型。Gets the runtime type of the current instance.

(Inherited from Exception)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

创建并返回当前异常的字符串表示形式。Creates and returns a string representation of the current exception.

(Inherited from Exception)

事件

SerializeObjectState SerializeObjectState SerializeObjectState SerializeObjectState

当异常被序列化用来创建包含有关该异常的徐列出数据的异常状态对象时会出现该问题。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(Inherited from Exception)

适用于

另请参阅