EventMappingSettingsCollection.Add(EventMappingSettings) 方法

定义

EventMappingSettings 对象添加到集合。

public:
 void Add(System::Web::Configuration::EventMappingSettings ^ eventMappingSettings);
public void Add (System.Web.Configuration.EventMappingSettings eventMappingSettings);
member this.Add : System.Web.Configuration.EventMappingSettings -> unit
Public Sub Add (eventMappingSettings As EventMappingSettings)

参数

eventMappingSettings
EventMappingSettings

要添加到集合的 EventMappingSettings 对象。

例外

集合中已经存在要添加的 EventMappingSettings 对象或该集合为只读。

示例

下面的代码示例说明如何使用 Add 方法。 此代码示例是为类提供的大型示例的 HealthMonitoringSection 一部分。

// Add a EventMappingsSettings object to the EventMappings collection property.
EventMappingSettings eventMappingSetting = new EventMappingSettings(
    "Failure Audits", "System.Web.Management.WebAuditEvent, System.Web");
eventMappingSetting.Name = "All Errors";
eventMappingSetting.Type = 
    "System.Web.Management.WebErrorEvent, System.Web";
eventMappingSetting.StartEventCode = 0;
eventMappingSetting.EndEventCode = 4096;
healthMonitoringSection.EventMappings.Add(eventMappingSetting);
' Add a EventMappingsSettings object to the EventMappings collection property.
Dim eventMappingSetting As EventMappingSettings = New EventMappingSettings( _
    "Failure Audits", "System.Web.Management.WebAuditEvent, System.Web")
eventMappingSetting.Name = "All Errors"
eventMappingSetting.Type = _
    "System.Web.Management.WebErrorEvent, System.Web"
eventMappingSetting.StartEventCode = 0
eventMappingSetting.EndEventCode = 4096
healthMonitoringSection.EventMappings.Add(eventMappingSetting)

注解

集合不能包含 EventMappingSettings 具有相同名称的对象。

适用于

另请参阅