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

和自甴很熟 提交于 2019-11-29 23:36:12

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.

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

I've spent good few hours on that issue, following all the instructions found on the web, so I've decided to share my solution, maybe it will save some time for the others. Finally I got a hint under one of the link in comments:

You’ll need to run Visual Studio as an administrator

My app is using MassTrasit with RabbitMQ, and it was failing on sending messages to the queue. Apparently it adds some perf counters under the hood and it was failing without Admin privileges with that very descriptive error. Funny thing you will need to run it as admin only first time (that's what deceived me).

I was getting this misleading error on my deployment machine, I was catching the error using FirstChanceException Mechanism, The IIS was repeatedly stopping the related Application Pool after occurring this error and I was getting the 'Service Unavailable' error when calling the site,

I tried many days to stop the counters or find/add the related counters but it did not work.

So I installed the VS on the server and debugged and noticed that I have been calling a non awaitable Linq query inside a async action which is not correctly conducted and accordingly there is a bug in application threading , and when there is many site visitors this bug shows up and IIS throws this exception and stops working.

after checking ShuggyCoUk answer and other answers if you are still getting the error, My advice is to consider checking related async functions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!