The following methods fails saying it cannot convert from type System.Collections.DcitionaryEntry to type System.Diagnostics.InstanceDataCollection. I've tried type casting, but to no avail. If I iterate through the DemoCollection DictionaryEntry objects, I haven't found a way to get at the InstanceDataCollection that should be hidden somewhere in this object. How can I fix this?
Code Snippet
static void ReadPerformanceCounterCategories()
{
//ReadCategory reads all the counter and performance object instace data associated with this category
PerformanceCounterCategory DemoCounterCategory = new PerformanceCounterCategory(".NET CLR Memory");
InstanceDataCollectionCollection DemoCollection = DemoCounterCategory.ReadCategory();
//IDictionaryEnumerator enumer = DemoCollection.GetEnumerator();
Debug.Assert(DemoCollection != null, "DemoCollection is null");
foreach (InstanceDataCollection thisCollection in DemoCollection)
{
Console.WriteLine(thisCollection.CounterName);
}
}