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
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.5為目標時,才會有相關的例外狀況。Specifically, 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 應用程式中載入 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 4,通常會報告 XAML 處理例外狀況的 XamlParseException 例外狀況是在不同的命名空間(System.Xaml)和不同的元件(system.string)中定義。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 目標,否則您通常不會從自己的程式碼擲回 XamlParseExceptionUnless 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 事件處理常式是處理執行時間 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安全性考慮或 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 區塊放在 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 類別的新執行個體。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)

適用於

另請參閱