2

私はこの簡単なコードを持っています:

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

    // create logic…
}

私のマシンで動作します。サーバーで実行すると、次のスタック トレースが得られます。

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) 

カテゴリはサーバー上に存在し、perfmonGUI で確認できます。

4

1 に答える 1

6

これはパフォーマンス カウンター メカニズムのエラーです。次のスクリプトで修正する必要があります。

cd %systemroot%\system32
lodctr /R

このリンクをチェックしてください: http://geekswithblogs.net/robz/archive/2008/08/10/possible-performance-counter-corruption-or-performance-counters-are-just-disabled.aspx

于 2012-12-17T09:21:52.683 に答える