XamlParseException 類別

定義

表示來自 WPF XAML 剖析器之剖析器特有例外狀況的例外狀況類別。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 剖析器作業,或特別供 WPF XAML 剖析器在呼叫 XamlReader API 時使用。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.5 為目標時,例外狀況才會相關。Specifically, the exception is only relevant when an application targets .NET Framework 3.0 and .NET Framework 3.5. 例外狀況也可能源自于執行時間呼叫中的使用者程式碼,而這些 Api 會連接 WPF 所執行的 XAML 剖析器,以從執行中的 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, XamlParseException 通常會報告 XAML 處理例外狀況的例外狀況是在不同的命名空間中定義 (System.Xaml) 以及不同的元件 (system.object) 。For .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.5 目標,否則您通常不會 XamlParseException 從自己的程式碼中擲回。Unless you are writing an equivalent to the WPF XAML parser or working with .NET Framework 3.0 and .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 的 xaml 安全性考慮 或 xaml 安全性章節 (WPF) 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 指示詞Gets 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()

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 ExceptionWhen 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)

適用於