This documentation is archived and is not being maintained.

PerformanceCounterInstaller Class

Specifies an installer for the PerformanceCounter component.

Namespace:  System.Diagnostics
Assembly:  System.Configuration.Install (in System.Configuration.Install.dll)

public class PerformanceCounterInstaller : ComponentInstaller

The following information might help provide a performance improvement when installing performance counters at application startup. Performance counter categories installed with .NET Framework version 2.0 use separate shared memories, with each performance counter category having its own memory. You can specify the size of separate shared memory by creating a DWORD named FileMappingSize in the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<category name>\Performance. The FileMappingSize value is set to the shared memory size of the category. The default size is 131072 decimal. If the FileMappingSize value is not present, the fileMappingSize attribute value for the performanceCounters element specified in the Machine.config file is used, causing additional overhead for configuration file processing. You can realize a performance improvement for application startup by setting the file mapping size in the registry.

The following code example demonstrates how to create a PerformanceCounterInstaller object and add it to an InstallerCollection.

using System;
using System.Configuration.Install;
using System.Diagnostics;
using System.ComponentModel;

public class MyPerformanceCounterInstaller: Installer
   public MyPerformanceCounterInstaller()
         // Create an instance of 'PerformanceCounterInstaller'.
         PerformanceCounterInstaller myPerformanceCounterInstaller =
            new PerformanceCounterInstaller();
         // Set the 'CategoryName' for performance counter.
         myPerformanceCounterInstaller.CategoryName =
         CounterCreationData myCounterCreation = new CounterCreationData();
         myCounterCreation.CounterName = "MyCounter";
         myCounterCreation.CounterHelp = "Counter Help";
         // Add a counter to collection of  myPerformanceCounterInstaller.
      catch(Exception e)
         Console.WriteLine("Error occured :"+e.Message);
   public static void Main()

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0