Invalid Index Exception trying to load Counter Name

perfctr

 

 

This happened to me yesterday, and of course, Stack Overflow to the rescue.  But it’s such a rare occurrence that I thought I would blog about it.  Here’s the SO link

The offending line of code, which was working perfectly for months until yesterday:

cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);

And I hope that “tdc” doesn’t mind me reposting his answer here:

Although this has already been answered, I see people are repeatedly getting the same error that I did when trying to solve it. If when you run:

C:\windows\system32> lodctr /r

you get the error

Error: Unable to rebuild performance counter setting from system backup store, error code is 2

then you instead need to run

C:\windows\SysWOW64> lodctr /r

after which you should get

Info: Successfully rebuilt performance counter setting from system backup store

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s