PerformanceCounterInstaller 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定 PerformanceCounter 组件的安装程序。
public ref class PerformanceCounterInstaller : System::Configuration::Install::ComponentInstallerpublic class PerformanceCounterInstaller : System.Configuration.Install.ComponentInstallertype PerformanceCounterInstaller = class
    inherit ComponentInstallerPublic Class PerformanceCounterInstaller
Inherits ComponentInstaller- 继承
示例
下面的代码示例演示如何创建 PerformanceCounterInstaller 对象并将其添加到 InstallerCollection。
#using <System.dll>
#using <System.Configuration.Install.dll>
using namespace System;
using namespace System::Configuration::Install;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
[RunInstaller(true)]
ref class MyPerformanceCounterInstaller: public Installer
{
public:
   MyPerformanceCounterInstaller()
   {
      try
      {
         // Create an instance of 'PerformanceCounterInstaller'.
         PerformanceCounterInstaller^ myPerformanceCounterInstaller =
            gcnew PerformanceCounterInstaller;
         // Set the 'CategoryName' for performance counter.
         myPerformanceCounterInstaller->CategoryName =
            "MyPerformanceCounter";
         CounterCreationData^ myCounterCreation = gcnew CounterCreationData;
         myCounterCreation->CounterName = "MyCounter";
         myCounterCreation->CounterHelp = "Counter Help";
         // Add a counter to collection of  myPerformanceCounterInstaller.
         myPerformanceCounterInstaller->Counters->Add( myCounterCreation );
         Installers->Add( myPerformanceCounterInstaller );
      }
      catch ( Exception^ e ) 
      {
          this->Context->LogMessage( "Error occurred : " + e->Message );
      }
   }
};
using System;
using System.Configuration.Install;
using System.Diagnostics;
using System.ComponentModel;
[RunInstaller(true)]
public class MyPerformanceCounterInstaller : Installer
{
    public MyPerformanceCounterInstaller()
    {
        try
        {
            // Create an instance of 'PerformanceCounterInstaller'.
            PerformanceCounterInstaller myPerformanceCounterInstaller =
               new PerformanceCounterInstaller();
            // Set the 'CategoryName' for performance counter.
            myPerformanceCounterInstaller.CategoryName =
               "MyPerformanceCounter";
            CounterCreationData myCounterCreation = new CounterCreationData();
            myCounterCreation.CounterName = "MyCounter";
            myCounterCreation.CounterHelp = "Counter Help";
            // Add a counter to collection of  myPerformanceCounterInstaller.
            myPerformanceCounterInstaller.Counters.Add(myCounterCreation);
            Installers.Add(myPerformanceCounterInstaller);
        }
        catch (Exception e)
        {
            this.Context.LogMessage("Error occurred :" + e.Message);
        }
    }
    public static void Main()
    {
    }
}
Imports System.Configuration.Install
Imports System.Diagnostics
Imports System.ComponentModel
<RunInstaller(True)> _
Public Class MyPerformanceCounterInstaller
    Inherits Installer
    Public Sub New()
        Try
            ' Create an instance of 'PerformanceCounterInstaller'.
            Dim myPerformanceCounterInstaller As New PerformanceCounterInstaller()
            ' Set the 'CategoryName' for performance counter.
            myPerformanceCounterInstaller.CategoryName = "MyPerformanceCounter"
            Dim myCounterCreation As New CounterCreationData()
            myCounterCreation.CounterName = "MyCounter"
            myCounterCreation.CounterHelp = "Counter Help"
            ' Add a counter to collection of  myPerformanceCounterInstaller.
            myPerformanceCounterInstaller.Counters.Add(myCounterCreation)
            Installers.Add(myPerformanceCounterInstaller)
        Catch e As Exception
            Me.Context.LogMessage("Error occurred :" + e.Message)
        End Try
    End Sub
    Public Shared Sub Main()
    End Sub
End Class
注解
以下信息可能有助于在应用程序启动时安装性能计数器时提供性能改进。 随 .NET Framework 版本 2.0 一起安装的性能计数器类别使用单独的共享内存,每个性能计数器类别都有自己的内存。 可以通过在注册表项中创建名为 FileMappingSize 的 DWORD 来指定单独的共享内存的大小,HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<类别名称>\Performance。 FileMappingSize 值设置为类别的共享内存大小。 默认大小为十进制131072。 如果 FileMappingSize 值不存在,则 fileMappingSize 使用 Machine.config 文件中指定的元素的属性值 performanceCounters ,从而导致配置文件处理产生额外的开销。 通过在注册表中设置文件映射大小,可以实现应用程序启动的性能改进。
构造函数
| PerformanceCounterInstaller() | 初始化 PerformanceCounterInstaller 类的新实例。 | 
属性
| CanRaiseEvents | 获取一个指示组件是否可以引发事件的值。(继承自 Component) | 
| CategoryHelp | 获取或设置性能计数器的描述性消息。 | 
| CategoryName | 获取或设置性能计数器的性能类别名称。 | 
| CategoryType | 获取或设置性能计数器类别类型。 | 
| Container | 获取包含 IContainer 的 Component。(继承自 Component) | 
| Context | 获取或设置关于当前安装的信息。(继承自 Installer) | 
| Counters | 获取与要安装的计数器有关的数据集合。 | 
| DesignMode | 获取一个值,用以指示 Component 当前是否处于设计模式。(继承自 Component) | 
| Events | 获取附加到此 Component 的事件处理程序的列表。(继承自 Component) | 
| HelpText | 获取安装程序集合中所有安装程序的帮助文字。(继承自 Installer) | 
| Installers | 获取该安装程序包含的安装程序的集合。(继承自 Installer) | 
| Parent | 获取或设置包含该安装程序所属的集合的安装程序。(继承自 Installer) | 
| Site | (继承自 Component) | 
| UninstallAction | 获取一个值,该值指示在卸载时是否移除性能计数器 | 
方法
事件
| AfterInstall | 在 Installers 属性中的所有安装程序的 Install(IDictionary) 方法都运行后发生。(继承自 Installer) | 
| AfterRollback | 在回滚 Installers 属性中所有安装程序的安装后发生。(继承自 Installer) | 
| AfterUninstall | 在 Installers 属性中所有安装程序都执行它们的卸载操作后发生。(继承自 Installer) | 
| BeforeInstall | 在安装程序集合中每个安装程序的 Install(IDictionary) 方法运行前发生。(继承自 Installer) | 
| BeforeRollback | 在回滚 Installers 属性中的安装程序前发生。(继承自 Installer) | 
| BeforeUninstall | 在 Installers 属性中的安装程序执行它们的卸载操作前发生。(继承自 Installer) | 
| Committed | 在 Installers 属性中的所有安装程序均提交它们的安装后发生。(继承自 Installer) | 
| Committing | 在 Installers 属性中的安装程序提交它们的安装前发生。(继承自 Installer) | 
| Disposed | 在通过调用 Dispose() 方法释放组件时发生。(继承自 Component) |