Reading performance counter from C#: Instance does not exist in the specified category

后端 未结 1 427
旧巷少年郎
旧巷少年郎 2020-12-17 19:40

I\'m trying to read a number of performance counters from a running .NET 4 application, from another .NET 4 application.

Some counters, such as Process\\% Proc

相关标签:
1条回答
  • 2020-12-17 20:25

    There are two settings for a project that can be relevant to your problem.

    First and foremost, Project + Properties, Build tab, Platform target. On a machine with a 64-bit operating system, setting this to x86 will get you a list of instance names that do not include 64-bit processes. Perfmon.exe is a 64-bit process, it shows all instances, both 32-bit and 64-bit apps. Get the same behavior by setting the Platform target to AnyCPU, that's not the default anymore on Visual Studio 2010. Untick "Prefer 32-bit" if you see it.

    Second is Project + Properties, Debug tab, "Enable the Visual Studio hosting process" option. When checked, you are debugging an process named yourapp.vshost.exe instead of yourapp.exe. That also affects the instance name, it will be yourapp.vshost. Not likely to be the problem in your specific case.

    Be sure to update your question with this essential info if this guess wasn't accurate.

    0 讨论(0)
提交回复
热议问题