Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am getting repeated errors about the ReadOnly property on performance counters whenever I try to debug a .NET windows service app. This app works fine on x86 windows vista, or x86 windows 2003. It's just stopped working on my new 64bit dev machine.

I've run the relevant InstallUtil invocations on 64bit and 32bit command line VCVARS.bat, in admin mode. I get no errors setting up the category and each perf counter. But, regardless of whether I set the perf ctrs as readonly or not, I get this:

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

UPDATE

I re-installed the machine with a 32bit version of Windows 7, and bizarrely I still get this error. The only thing that has changed is moving from Windows Vista Business to Windows 7 Professional. Does this ring any bells?

like image 599
Andrew Matthews Avatar asked Jan 12 '10 04:01

Andrew Matthews


People also ask

How do I fix a corrupted performance counter?

Solution #1 - Automatic The first solution to try when Windows performance counters are known to be corrupt is attempt to automatically restore the performance counter registry settings. This is done by running a single command from the Windows Command Prompt.

Which of the following exception performance counters in dotnet framework?

Exception performance counters. The Performance console . NET CLR Exceptions category includes counters that provide information about the exceptions thrown by an application.


2 Answers

This is due to the performance counter (or category) not existing, but with a horrible error message.

Take a look in perfmon for the counter, it should be missing on the relevant machines.

I find this happens to the .Net perf counters sometimes (no idea why) but using lodctr1 gets them back. If you indicate which perf counter you are trying to get at we might be able to give you more help.

  1. Note that the example lined is for .Net 1.1, adjust for different frameworks accordingly.
like image 190
ShuggyCoUk Avatar answered Oct 05 '22 13:10

ShuggyCoUk


I ran into a variant of this issue, while I could see the .net performance counter tab in reflector it actually had no counters in it.

I had to re-add them

lodctr /R cd C:\Windows\Inf\.NETFramework lodctr corperfmonsymbols.ini 
like image 20
Daniel Little Avatar answered Oct 05 '22 12:10

Daniel Little