Under the ".NET CLR Memory" performance counter category, there is a counter named "Process ID". Any given instance of this counter is supposed to return the Process Id of the Windows process associated with the instance. For my own processes, this counter always has a zero value. Why is that?
If I look at the devenv
instance of the counter, it returns the expected value - at least, the value matches the process id reported by Task Manager.
If I run my own application in Debug mode and examine the PerfCounterTest.vshost
instance of the counter, it only ever has the value zero.
If I run my own application without the debugger, the PerfCounterTest
instance is always zero.
If I run several instances of my own application, the sequence-numbered instances PerfCounterTest#1
, PerfCounterTest#2
... all have the value zero.
Why is this counter always zero and, seeing as it is always zero, how do I find the instance-name associated with my process, bearing in mind that it may not have a unique name?