问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/13902516/failure-in-delete-performance-counter-category