EventSource Constructors

Definition

Creates a new instance of the EventSource class.

Overloads

EventSource()

Creates a new instance of the EventSource class.

EventSource(Boolean)

Creates a new instance of the EventSource class and specifies whether to throw an exception when an error occurs in the underlying Windows code.

EventSource(EventSourceSettings)

Creates a new instance of the EventSource class with the specified configuration settings.

EventSource(String)

Creates a new instance of the EventSource class with the specified name.

EventSource(EventSourceSettings, String[])

Initializes a new instance of the EventSource to be used with non-contract events that contains the specified settings and traits.

EventSource(String, EventSourceSettings)

Creates a new instance of the EventSource class with the specified name and settings.

EventSource(String, EventSourceSettings, String[])

Creates a new instance of the EventSource class with the specified configuration settings.

EventSource()

Creates a new instance of the EventSource class.

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

Applies to

EventSource(Boolean)

Creates a new instance of the EventSource class and specifies whether to throw an exception when an error occurs in the underlying Windows code.

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

Parameters

throwOnEventWriteErrors
Boolean

true to throw an exception when an error occurs in the underlying Windows code; otherwise, false.

Applies to

EventSource(EventSourceSettings)

Creates a new instance of the EventSource class with the specified configuration settings.

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)

Parameters

settings
EventSourceSettings

A bitwise combination of the enumeration values that specify the configuration settings to apply to the event source.

Remarks

Specifying settings when the EventSource is constructed enables you to specify whether the event is written in a manifest-based or a self-describing format. In addition, you can specify that an exception should be raised when an error occurs during the event-writing process.

Applies to

EventSource(String)

Creates a new instance of the EventSource class with the specified name.

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)

Parameters

eventSourceName
String

The name to apply to the event source. Must not be null.

Exceptions

eventSourceName is null.

Remarks

When using this constructor, ensure that the eventSourceName argument matches the ETW name defined by the EventSourceAttribute attribute on that type. Otherwise, the GUIDs returned by the Guid property and the GetGuid(Type) method will be different. If the event source names differ, the Guid property returns the GUID used to register this EventSource with ETW.

Applies to

EventSource(EventSourceSettings, String[])

Initializes a new instance of the EventSource to be used with non-contract events that contains the specified settings and traits.

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())

Parameters

settings
EventSourceSettings

A bitwise combination of the enumeration values that specify the configuration settings to apply to the event source.

traits
String[]

The key-value pairs that specify traits for the event source.

Exceptions

traits is not specified in key-value pairs.

Remarks

Traits provide additional information for an event and are interpreted by an event listener. Traits are specified as key-value pairs and if not specified in pairs, an exception will occur. You can retrieve a trait by passing the key to the GetTrait, method.

Specifying settings when the EventSource is constructed enables you to specify whether the event is written in a manifest-based or a self-describing format. In addition, you can specify that an exception should be raised when an error occurs during the event-writing process.

See also

Applies to

EventSource(String, EventSourceSettings)

Creates a new instance of the EventSource class with the specified name and settings.

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)

Parameters

eventSourceName
String

The name to apply to the event source. Must not be null.

config
EventSourceSettings

A bitwise combination of the enumeration values that specify the configuration settings to apply to the event source.

Exceptions

eventSourceName is null.

Remarks

Specifying settings when the EventSource is constructed enables you to specify whether the event is written in a manifest-based or a self-describing format. In addition, you can specify that an exception should be raised when an error occurs during the event-writing process.

When using this constructor, ensure that the eventSourceName argument matches the ETW name defined by the EventSourceAttribute attribute on that type. Otherwise, the GUIDs returned by the Guid property and the GetGuid(Type) method will be different.

In such cases, the Guid property returns the GUID used to register this EventSource with ETW.

Applies to

EventSource(String, EventSourceSettings, String[])

Creates a new instance of the EventSource class with the specified configuration settings.

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())

Parameters

eventSourceName
String

The name to apply to the event source. Must not be null.

config
EventSourceSettings

A bitwise combination of the enumeration values that specify the configuration settings to apply to the event source.

traits
String[]

The key-value pairs that specify traits for the event source.

Exceptions

eventSourceName is null.

traits is not specified in key-value pairs.

Remarks

Traits provide additional information for an event and are interpreted by an event listener. Traits are specified as key-value pairs and if not specified in pairs, an exception will occur. You can retrieve a trait by passing the key to the GetTrait, method.

Specifying config when the EventSource is constructed enables you to specify whether the event is written in a manifest-based or a self-describing format. In addition, you can specify that an exception should be raised when an error occurs during the event-writing process.

When using this constructor, ensure that the eventSourceName argument matches the ETW name defined by the EventSourceAttribute attribute on that type. Otherwise, the GUIDs returned by the Guid property and the GetGuid(Type) method will be different.

In such cases, the GUID used to register this EventSource with ETW is the one returned by Guid.

See also

Applies to