Performance Counter - System.InvalidOperationException: Category does not exist
I have following class that returns number of current Request per Second of IIS. I call RefreshCounters every minute in order to keep Requests per Second value refreshed (because it is average and if I keep it too long old value will influence result too much)... and when I need to display current RequestsPerSecond I call that property. public class Counters { private static PerformanceCounter pcReqsPerSec; private const string counterKey = "Requests_Sec"; public static object RequestsPerSecond { get { lock (counterKey) { if (pcReqsPerSec != null) return pcReqsPerSec.NextValue().ToString("N2")