here i talked about instrumenting your applications with Windows Performance Counters. A number of people asked me how to install such a counter during deployment.
The easiest way is to derive from a class called PerformanceCounterInstaller, set the appropriate properties and run it (from an admin priv account) with installutil.exe. The System.Diagnostics namespace also provides APIs to manually create and remove counters. Here is a sample how to install the two counters I used in my previous article.
public class MyInstaller : PerformanceCounterInstaller
this.CategoryName = “SuspiciousActivity”;
CounterCreationData ccd1 = new CounterCreationData(
“Total Numbers of Validation Errors”,
CounterCreationData ccd2 = new CounterCreationData(
“Validation Errors per Second”,