Windows-Server-2008

請求的性能計數器不是自定義計數器,它必須初始化為 ReadOnly

  • January 23, 2015

我在網站的生產環境(Windows Server 2008、IIS 7)中收到此錯誤。

The requested Performance Counter is not a custom counter, it has to be initialized 
as ReadOnly.

Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where
it originated in the code. 

Exception Details: System.InvalidOperationException: The requested Performance Counter 
is not a custom counter, it has to be initialized as ReadOnly.

Source Error: 

An unhandled exception was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be identified using
the exception stack trace below.

Stack Trace: 


[InvalidOperationException: The requested Performance Counter is not a custom counter,
it has to be initialized as ReadOnly.]
System.Diagnostics.PerformanceCounter.InitializeImpl() +1238
System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName,
String instanceName, Boolean readOnly) +284
Microsoft.EnterpriseInstrumentation.EventSourceCounters..ctor(String eventSourceName,
String eventSourceFullName, Boolean isRequestEventSource) +463
Microsoft.EnterpriseInstrumentation.EventSource..ctor(String name, String description, 
Boolean checkName) +785
Microsoft.EnterpriseInstrumentation.EventSource..cctor() +194

那我怎麼解決?

我通過安裝 Microsoft 企業庫解決了它,然後執行“c:\program files\microsoft enterprise library 5.0\InstallServices.bat”

注意:在安裝時,我看到了一些對性能計數器的引用,請參見下面的螢幕截圖:

在此處輸入圖像描述

引用自:https://serverfault.com/questions/339307