PerformanceCounter Constructor (String, String, String)
Assembly: System (in system.dll)
public PerformanceCounter ( string categoryName, string counterName, string instanceName )
public function PerformanceCounter ( categoryName : String, counterName : String, instanceName : String )
The name of the performance counter category (performance object) with which this performance counter is associated.
The name of the performance counter.
The name of the performance counter category instance, or an empty string (""), if the category contains a single instance.
The categoryName is an empty string ("").
The counterName is an empty string ("").
The category specified is not valid.
The category specified is marked as multi-instance and requires the performance counter to be created with an instance name.
The instanceName is longer than 127 characters.
The categoryName or counterName parameter is a null reference (Nothing in Visual Basic).
An error occurred when accessing a system API.
The platform is Windows 98 or Windows Millennium Edition (Me), which does not support performance counters.
The parameter strings are not case sensitive.
This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the CategoryName, CounterName, and InstanceName properties must point to an existing performance counter on the local computer. If the performance counter instance you point to is not valid, calling the constructor throws an exception.
This overload can access any read-only or read/write counter, but does so in a read-only mode. A PerformanceCounter instance created using this overload cannot write to the counter, even if the counter itself is read/write.
To create a performance category instance, specify an instanceName on the PerformanceCounter constructor. If the category instance specified by instanceName already exists the new object will reference the existing category instance.
- PerformanceCounterPermission for reading the performance counter category if the ReadOnly property is true. Associated enumeration: PerformanceCounterPermissionAccess.Read.
- PerformanceCounterPermission for writing the performance counter category if the ReadOnly property is false. Associated enumeration: PerformanceCounterPermissionAccess.Write.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.