我在网站的生产环境(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
我该如何解决呢?
答案1
我通过安装 Microsoft 企业库,然后运行“c:\program files\microsoft enterprise library 5.0\InstallServices.bat”解决了这个问题
注意:安装时,我看到一些对性能计数器的引用,见下面的屏幕截图: