EventSource 构造函数 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建 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()
- Source:
- EventSource.cs
- Source:
- EventSource.cs
- Source:
- EventSource.cs
创建 EventSource 类的新实例。
protected:
 EventSource();protected EventSource ();Protected Sub New ()适用于
EventSource(Boolean)
- Source:
- EventSource.cs
- Source:
- EventSource.cs
- Source:
- EventSource.cs
创建 EventSource 类的新实例,并指定在 Windows 基础代码发生错误时是否引发异常。
protected:
 EventSource(bool throwOnEventWriteErrors);protected EventSource (bool throwOnEventWriteErrors);new System.Diagnostics.Tracing.EventSource : bool -> System.Diagnostics.Tracing.EventSourceProtected Sub New (throwOnEventWriteErrors As Boolean)参数
- throwOnEventWriteErrors
- Boolean
在从属位置的 Windows 代码生成引发异常,则为 true;否则为 false。
适用于
EventSource(EventSourceSettings)
- Source:
- EventSource.cs
- Source:
- EventSource.cs
- Source:
- EventSource.cs
使用指定的配置设置创建 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.EventSourceProtected Sub New (settings As EventSourceSettings)参数
- settings
- EventSourceSettings
一个枚举值的按位组合,这些枚举值指定要应用于事件源的配置设置。
注解
通过 settings 指定构造 时 EventSource ,可以指定事件是以基于清单的格式还是以自描述格式写入的。 此外,还可以指定在事件写入过程中发生错误时应引发异常。
适用于
EventSource(String)
- Source:
- TraceLoggingEventSource.cs
- Source:
- TraceLoggingEventSource.cs
- Source:
- TraceLoggingEventSource.cs
使用指定的名称创建 EventSource 类的新实例。
public:
 EventSource(System::String ^ eventSourceName);public EventSource (string eventSourceName);new System.Diagnostics.Tracing.EventSource : string -> System.Diagnostics.Tracing.EventSourcePublic Sub New (eventSourceName As String)参数
- eventSourceName
- String
要应用于事件源的名称。 不得为 null。
例外
              eventSourceName 为 null。
注解
使用此构造函数时,请确保 eventSourceName 参数与该类型上的 特性定义的 EventSourceAttribute ETW 名称匹配。 否则, 属性和 GetGuid(Type) 方法返回Guid的 GUID 将不同。 如果事件源名称不同,则 Guid 属性返回用于向 ETW 注册此 EventSource 的 GUID。
适用于
EventSource(EventSourceSettings, String[])
- Source:
- EventSource.cs
- Source:
- EventSource.cs
- Source:
- EventSource.cs
初始化 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.EventSourceProtected Sub New (settings As EventSourceSettings, ParamArray traits As String())参数
- settings
- EventSourceSettings
一个枚举值的按位组合,这些枚举值指定要应用于事件源的配置设置。
- traits
- String[]
指定事件源特性的键值对。
例外
键值对中未指定 traits。
注解
特征为事件提供其他信息,并由事件侦听器解释。 特征指定为键值对,如果未在对中指定,将发生异常。 可以通过将 键传递给 GetTrait方法来检索特征。
通过 settings 指定构造 时 EventSource ,可以指定事件是以基于清单的格式还是以自描述格式写入的。 此外,还可以指定在事件写入过程中发生错误时应引发异常。
另请参阅
适用于
EventSource(String, EventSourceSettings)
- Source:
- TraceLoggingEventSource.cs
- Source:
- TraceLoggingEventSource.cs
- Source:
- TraceLoggingEventSource.cs
使用指定的名称和设置创建 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.EventSourcePublic Sub New (eventSourceName As String, config As EventSourceSettings)参数
- eventSourceName
- String
要应用于事件源的名称。 不得为 null。
- config
- EventSourceSettings
一个枚举值的按位组合,这些枚举值指定要应用于事件源的配置设置。
例外
              eventSourceName 为 null。
注解
通过 settings 指定构造 时 EventSource ,可以指定事件是以基于清单的格式还是以自描述格式写入的。 此外,还可以指定在事件写入过程中发生错误时应引发异常。
使用此构造函数时,请确保 eventSourceName 参数与该类型上的 特性定义的 EventSourceAttribute ETW 名称匹配。 否则, 属性和 GetGuid(Type) 方法返回Guid的 GUID 将不同。
在这种情况下, Guid 属性返回用于向 ETW 注册此 EventSource 的 GUID。
适用于
EventSource(String, EventSourceSettings, String[])
- Source:
- TraceLoggingEventSource.cs
- Source:
- TraceLoggingEventSource.cs
- Source:
- TraceLoggingEventSource.cs
使用指定的配置设置创建 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.EventSourcePublic Sub New (eventSourceName As String, config As EventSourceSettings, ParamArray traits As String())参数
- eventSourceName
- String
要应用于事件源的名称。 不得为 null。
- config
- EventSourceSettings
一个枚举值的按位组合,这些枚举值指定要应用于事件源的配置设置。
- traits
- String[]
指定事件源特性的键值对。
例外
              eventSourceName 为 null。
键值对中未指定 traits。
注解
特征为事件提供其他信息,并由事件侦听器解释。 特征指定为键值对,如果未在对中指定,将发生异常。 可以通过将 键传递给 GetTrait方法来检索特征。
通过 config 指定构造 时 EventSource ,可以指定事件是以基于清单的格式还是以自描述格式写入的。 此外,还可以指定在事件写入过程中发生错误时应引发异常。
使用此构造函数时,请确保 eventSourceName 参数与该类型上的 特性定义的 EventSourceAttribute ETW 名称匹配。 否则, 属性和 GetGuid(Type) 方法返回Guid的 GUID 将不同。
在这种情况下,用于将此 EventSource 注册到 ETW 的 GUID 是由 返回的 Guid。