Groups | Blog | Home
all groups > dotnet performance > october 2004 >

dotnet performance : Can't create performance counter instances


Nick Bennett
10/19/2004 5:41:01 AM
I've managed to create a performance category with a single counter in it. I
then try to create instances of this counter, but when I go into perfmon, I
can't see any instances. And the category itself says it hasn't got any
instances when I call GetInstanceNames() on it.

What am I doing wrong?

Here's the bit of code I am using to do this stuff:

CounterCreationDataCollection counterData = new
CounterCreationDataCollection();
counterData.Add(new CounterCreationData(
"Counter",
"Something",
PerformanceCounterType.NumberOfItems32));

PerformanceCounterCategory.Create("Temp", "This is a sandbox", counterData);
PerformanceCounter.CloseSharedResources();

new PerformanceCounter("Temp", "Counter", "The Instance", false).RawValue = 0;
new PerformanceCounter("Temp", "Counter", "Another Instance",
false).RawValue = 0;
PerformanceCounter.CloseSharedResources();
Don
3/14/2005 3:11:03 PM
Nick,

Did you figure out the problem? I'm having what seems like the same problem.
I can create single instance performance counters, but when I create multiple
instance ones they are not readable (perfmon thinks they are single instance,
so does the PerformanceCounter object when used to read them) --
interestingly enough, I don't get any errors writing to them??

[quoted text, click to view]
AddThis Social Bookmark Button