Your WMI class path is wrong ( or you are confusing performance counter
object names with WMI class paths).
The class you are looking for is
"Win32_PerfFormattedData_NETFramework_NETCLRMemory" and an instance of this
class is something like:
Win32_PerfFormattedData_NETFramework_NETCLRMemory.Name
="ManagedProgramNameHere"
Following sample dumps all currently running managed apps. and show their
GC2 heap usage.
using System;
using System.Management;
class App {
public static void Main() {
SelectQuery query = new
SelectQuery("Win32_PerfFormattedData_NETFramework_NETCLRMemory");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject mo in searcher.Get()) {
Console.WriteLine("{0} ",mo["Name"]);
using(ManagementObject o = new
ManagementObject(mo["__RelPath"].ToString()))
{
o.Get();
Console.WriteLine("GC2 heapsize = " + o["Gen2heapsize"] + " bytes");
}
}
}
}
Willy.