2

I have this simple code:

public void CreateCounters() {
    if (PerformanceCounterCategory.Exists(_categoryName)) {
        PerformanceCounterCategory.Delete(_categoryName);
    }

    // create logic…
}

works on my machine. I run it on my server, get the following stack trace:

System has detected a fatal error. EXITING... 
NativeErrorCode: 1010 
ErrorCode: -2147467259 
Message: The configuration registry key is invalid 
TargetSite: Void RegisterFiles(System.String, Boolean) 
HelpLink:  
Source: System 
Stack Trace: 
 at System.Diagnostics.PerformanceCounterLib.RegisterFiles(String arg0, Boolean unregister) 
 at System.Diagnostics.PerformanceCounterCategory.Delete(String categoryName) 
 at myApp.Common.Utils.PerformanceCounters.PerformanceCounters.CreateCounters() 
 at myApp.Common.Utils.PerformanceCounters.myAppPerformanceCounterReporter.Init() 
 at myApp.Common.Utils.PerformanceCounters.myAppPerformanceCounterReporter.get_Instance() 
 at myApp.Program.Main(String[] args) 

The category exists on the server, I can see it in perfmon GUI.

Ragunath Jawahar
  • 19,513
  • 22
  • 110
  • 155
user1025852
  • 2,684
  • 11
  • 36
  • 58

1 Answers1

6

ok this is some error in performance counter mechanis, that should be fixed by the following script :

cd %systemroot%\system32
lodctr /R

check out this link : http://geekswithblogs.net/robz/archive/2008/08/10/possible-performance-counter-corruption-or-performance-counters-are-just-disabled.aspx

Jay Bazuzi
  • 45,157
  • 15
  • 111
  • 168
user1025852
  • 2,684
  • 11
  • 36
  • 58