I have a strange problem creating new counters in existing group. I have a windows service, which does some work and allow me to monitor its state via performance counter. I have performance counters group and some performance counters. Group is created during service install phase (with administrator privileges), and counters are initialized when service starts (as LocalSystem user). Everything works fine, group exists, counter exist too, I can monitor them and write to Performance counters log. Service is constantly running.
Then I want to add some more performance counters. I add them in service code, rebuild and deploy to server by uninstalling previous service instance (performance counters group is deleted by uninstall code), and installing service again (performance counters group is created during install phase with all new counters). Then I start service.
That's the end of common, uninteresting part of the story. The strange things start here.
I go to PerMon, add all counters to System monitor view. I can see my performance counters group, I see all performance counters including NEW performance counters that I've just added. I can add them to System monitor view. And I can see, that old counters are working. But new counters doesn't work, they don't collect any data. Well, ok, perhaps there was my mistake, I switch to log view and try to log performance counters data. Old counters are logged as they logged before. But when I try to add new counter, I find in Event Viewer following warning:
The service was unable to add the counter '\AGENT\MyCountersGroupName\MyNewCounter' to the NewCountersLog log or alert. This log or alert will continue, but data for that counter will not be collected. The error returned is: The specified counter could not be found.
I tried to reinstall service, remove old counters, add them again, and nothing changed. Old counters are working, and new counters don