Installing Performance Counters

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.

using System;

using System.Diagnostics;
using System.ComponentModel;


namespace PerfCounterInstaller



  public class MyInstaller : PerformanceCounterInstaller


    public MyInstaller()


      this.CategoryName = “SuspiciousActivity”;


      CounterCreationData ccd1 = new CounterCreationData(


        “Total Numbers of Validation Errors”,



       CounterCreationData ccd2 = new CounterCreationData(


         “Validation Errors per Second”,









This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s