EventSource 建構函式

定義

建立 EventSource 類別的新執行個體。

多載

EventSource()

建立 EventSource 類別的新執行個體。

EventSource(Boolean)

建立 EventSource 類別的新執行個體,並指定當基礎 Windows 程式碼發生錯誤時是否擲回例外狀況。

EventSource(EventSourceSettings)

使用指定的組態設定,建立 EventSource 類別的新執行個體。

EventSource(String)

使用指定的名稱,建立 EventSource 類別的新執行個體。

EventSource(EventSourceSettings, String[])

初始化要與非合約事件搭配使用之 EventSource 的新執行個體,這些事件包含指定的設定和特性。

EventSource(String, EventSourceSettings)

使用指定的名稱和設定,建立 EventSource 類別的新執行個體。

EventSource(String, EventSourceSettings, String[])

使用指定的組態設定,建立 EventSource 類別的新執行個體。

EventSource()

建立 EventSource 類別的新執行個體。

protected:
 EventSource();
protected EventSource ();
Protected Sub New ()

適用於

EventSource(Boolean)

建立 EventSource 類別的新執行個體,並指定當基礎 Windows 程式碼發生錯誤時是否擲回例外狀況。

protected:
 EventSource(bool throwOnEventWriteErrors);
protected EventSource (bool throwOnEventWriteErrors);
new System.Diagnostics.Tracing.EventSource : bool -> System.Diagnostics.Tracing.EventSource
Protected Sub New (throwOnEventWriteErrors As Boolean)

參數

throwOnEventWriteErrors
Boolean

true 表示要在基礎 Windows 程式碼發生錯誤時擲回例外狀況,否則為 false

適用於

EventSource(EventSourceSettings)

使用指定的組態設定,建立 EventSource 類別的新執行個體。

protected:
 EventSource(System::Diagnostics::Tracing::EventSourceSettings settings);
protected EventSource (System.Diagnostics.Tracing.EventSourceSettings settings);
new System.Diagnostics.Tracing.EventSource : System.Diagnostics.Tracing.EventSourceSettings -> System.Diagnostics.Tracing.EventSource
Protected Sub New (settings As EventSourceSettings)

參數

settings
EventSourceSettings

列舉值的位元組合,可指定要套用至事件來源的組態設定。

備註

指定 settings 建構的時機 EventSource 可讓您指定事件是以資訊清單為基礎或自我描述格式撰寫。 此外,您也可以指定在事件寫入程式期間發生錯誤時,應該引發例外狀況。

適用於

EventSource(String)

使用指定的名稱,建立 EventSource 類別的新執行個體。

public:
 EventSource(System::String ^ eventSourceName);
public EventSource (string eventSourceName);
new System.Diagnostics.Tracing.EventSource : string -> System.Diagnostics.Tracing.EventSource
Public Sub New (eventSourceName As String)

參數

eventSourceName
String

要套用至事件來源的名稱。 必須不是 null

例外狀況

eventSourceNamenull

備註

使用此建構函式時,請確定自 eventSourceName 變數符合該類型上 屬性所 EventSourceAttribute 定義的 ETW 名稱。 否則,屬性傳 Guid 回的 GUID 和 GetGuid(Type) 方法將會不同。 如果事件來源名稱不同, Guid 屬性會傳回用來向 ETW 註冊此 EventSource 的 GUID。

適用於

EventSource(EventSourceSettings, String[])

初始化要與非合約事件搭配使用之 EventSource 的新執行個體,這些事件包含指定的設定和特性。

protected:
 EventSource(System::Diagnostics::Tracing::EventSourceSettings settings, ... cli::array <System::String ^> ^ traits);
protected EventSource (System.Diagnostics.Tracing.EventSourceSettings settings, params string[] traits);
protected EventSource (System.Diagnostics.Tracing.EventSourceSettings settings, params string[]? traits);
new System.Diagnostics.Tracing.EventSource : System.Diagnostics.Tracing.EventSourceSettings * string[] -> System.Diagnostics.Tracing.EventSource
Protected Sub New (settings As EventSourceSettings, ParamArray traits As String())

參數

settings
EventSourceSettings

列舉值的位元組合,可指定要套用至事件來源的組態設定。

traits
String[]

指定事件來源特性的機碼值組。

例外狀況

索引鍵/值組中未指定 traits

備註

特性會提供事件的其他資訊,並由事件接聽程式解譯。 特性會指定為索引鍵/值組,如果未在配對中指定,就會發生例外狀況。 您可以將金鑰傳遞至 <xref:System.Diagnostics.Tracing.EventSource.GetTrait%2A> , 方法,以擷取特徵。

指定 settings 建構的時機 EventSource 可讓您指定事件是以資訊清單為基礎或自我描述格式撰寫。 此外,您也可以指定在事件寫入程式期間發生錯誤時,應該引發例外狀況。

另請參閱

  • <xref:System.Diagnostics.Tracing.EventSource.GetTrait(System.String)>

適用於

EventSource(String, EventSourceSettings)

使用指定的名稱和設定,建立 EventSource 類別的新執行個體。

public:
 EventSource(System::String ^ eventSourceName, System::Diagnostics::Tracing::EventSourceSettings config);
public EventSource (string eventSourceName, System.Diagnostics.Tracing.EventSourceSettings config);
new System.Diagnostics.Tracing.EventSource : string * System.Diagnostics.Tracing.EventSourceSettings -> System.Diagnostics.Tracing.EventSource
Public Sub New (eventSourceName As String, config As EventSourceSettings)

參數

eventSourceName
String

要套用至事件來源的名稱。 必須不是 null

config
EventSourceSettings

列舉值的位元組合,可指定要套用至事件來源的組態設定。

例外狀況

eventSourceNamenull

備註

指定 settings 建構的時機 EventSource 可讓您指定事件是以資訊清單為基礎或自我描述格式撰寫。 此外,您也可以指定在事件寫入程式期間發生錯誤時,應該引發例外狀況。

使用此建構函式時,請確定自 eventSourceName 變數符合該類型上 屬性所 EventSourceAttribute 定義的 ETW 名稱。 否則,屬性傳 Guid 回的 GUID 和 GetGuid(Type) 方法將會不同。

在這種情況下, Guid 屬性會傳回用來向 ETW 註冊此 EventSource 的 GUID。

適用於

EventSource(String, EventSourceSettings, String[])

使用指定的組態設定,建立 EventSource 類別的新執行個體。

public:
 EventSource(System::String ^ eventSourceName, System::Diagnostics::Tracing::EventSourceSettings config, ... cli::array <System::String ^> ^ traits);
public EventSource (string eventSourceName, System.Diagnostics.Tracing.EventSourceSettings config, params string[] traits);
public EventSource (string eventSourceName, System.Diagnostics.Tracing.EventSourceSettings config, params string[]? traits);
new System.Diagnostics.Tracing.EventSource : string * System.Diagnostics.Tracing.EventSourceSettings * string[] -> System.Diagnostics.Tracing.EventSource
Public Sub New (eventSourceName As String, config As EventSourceSettings, ParamArray traits As String())

參數

eventSourceName
String

要套用至事件來源的名稱。 必須不是 null

config
EventSourceSettings

列舉值的位元組合,可指定要套用至事件來源的組態設定。

traits
String[]

指定事件來源特性的機碼值組。

例外狀況

eventSourceNamenull

索引鍵/值組中未指定 traits

備註

特性會提供事件的其他資訊,並由事件接聽程式解譯。 特性會指定為索引鍵/值組,如果未在配對中指定,就會發生例外狀況。 您可以將金鑰傳遞至 <xref:System.Diagnostics.Tracing.EventSource.GetTrait%2A> , 方法,以擷取特徵。

指定 config 建構的時機 EventSource 可讓您指定事件是以資訊清單為基礎或自我描述格式撰寫。 此外,您也可以指定在事件寫入程式期間發生錯誤時,應該引發例外狀況。

使用此建構函式時,請確定自 eventSourceName 變數符合該類型上 屬性所 EventSourceAttribute 定義的 ETW 名稱。 否則,屬性傳 Guid 回的 GUID 和 GetGuid(Type) 方法將會不同。

在這種情況下,用來向 ETW 註冊此 EventSource 的 GUID 是 所傳回的 GUID Guid

另請參閱

  • <xref:System.Diagnostics.Tracing.EventSource.GetTrait(System.String)>

適用於