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.
"Tamar Solutions" <Ja***@REMOVEMEtamarsolutions.co.uk> wrote in message
news:ch**********@newsg3.svr.pol.co.uk...
"Razzie" <ra****@quicknet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... would help if we'd know what error you are getting :)
"Tamar Solutions" <Ja***@REMOVEMEtamarsolutions.co.uk> wrote in message
news:ch**********@newsg1.svr.pol.co.uk... ManagementObject mo = new ManagementObject(".NET CLR MEMORY");
thanks -
JJ
Hi - Sorry... as below
An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll
Additional information: Invalid parameter