问题描述
每当我尝试调试 .NET Windows 服务应用程序时,我都会收到有关性能计数器上 ReadOnly 属性的重复错误.这个应用程序在 x86 windows vista 或 x86 windows 2003 上运行良好.它刚刚停止在我的新 64 位开发机器上运行.
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.
我已经在 64 位和 32 位命令行 VCVARS.bat 上以管理员模式运行了相关的 InstallUtil 调用.我得到设置类别和每个性能计数器没有错误.但是,无论我是否将 perf ctrs 设置为只读,我都会得到:
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.
更新
我用 32 位版本的 Windows 7 重新安装了机器,但奇怪的是我仍然收到此错误.唯一改变的是从 Windows Vista Business 迁移到 Windows 7 Professional.这会响铃吗?
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?
推荐答案
这是由于性能计数器(或类别)不存在,但有一个可怕的错误消息.
This is due to the performance counter (or category) not existing, but with a horrible error message.
在perfmon中查看计数器,相关机器上应该没有它.
Take a look in perfmon for the counter, it should be missing on the relevant machines.
我发现 .Net 性能计数器有时会发生这种情况(不知道为什么),但是 使用 lodctr1 让他们回来.如果您指出您要使用哪个性能计数器,我们可能会为您提供更多帮助.
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.
- 请注意,该示例适用于 .Net 1.1,请针对不同的框架进行相应调整.
这篇关于请求的性能计数器不是自定义计数器,它必须初始化为 ReadOnly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!