XamlParseException 类

定义

表示来自 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
public class XamlParseException : SystemException
[System.Serializable]
public class XamlParseException : SystemException
type XamlParseException = class
    inherit SystemException
[<System.Serializable>]
type XamlParseException = class
    inherit SystemException
Public Class XamlParseException
Inherits SystemException
继承
XamlParseException
属性

注解

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. 异常也可能源自用户代码,这些 Api 用于连接到由 WPF 实现的 XAML 分析器的 Api,以便从正在运行的 WPF 应用程序中加载 XAML (例如,调用 XamlReader.Load) 。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 4XamlParseException 通常会报告 XAML 处理异常的异常在不同的命名空间 (System.Xaml) 和 (system.exception) 的另一个程序集定义。For .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 分析错误, Dispatcher UnhandledException 应用程序级别的事件处理程序是处理运行时的一种方法 XamlParseExceptionFor 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 块放置在中 InitializeComponentTherefore another possible handling strategy is to place try/catch blocks in InitializeComponent. 但是,这种方法并不能很好地与模板、可视化设计图面以及挂钩的其他生成的源集成 InitializeComponentHowever, this technique does not integrate well with templates, visual design surfaces and other generated sources that hook up InitializeComponent.

构造函数

XamlParseException()

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

XamlParseException(SerializationInfo, StreamingContext)

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

XamlParseException(String)

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

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 类的新实例。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 类的新实例。Initializes a new instance of the XamlParseException class, using the specified exception message, inner exception, line number, and position in the line.

属性

BaseUri

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

Data

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

(继承自 Exception)
HelpLink

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

(继承自 Exception)
HResult

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

(继承自 Exception)
InnerException

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

(继承自 Exception)
KeyContext

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

LineNumber

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

LinePosition

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

Message

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

(继承自 Exception)
NameContext

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

Source

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

(继承自 Exception)
StackTrace

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

(继承自 Exception)
TargetSite

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

(继承自 Exception)
UidContext

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

方法

Equals(Object)

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

(继承自 Object)
GetBaseException()

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

(继承自 Exception)
GetHashCode()

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

(继承自 Object)
GetObjectData(SerializationInfo, StreamingContext)

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

GetType()

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

(继承自 Exception)
MemberwiseClone()

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

(继承自 Object)
ToString()

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

(继承自 Exception)

事件

SerializeObjectState

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

(继承自 Exception)

适用于

另请参阅