G
Guest
We are trying to create a custom performance counter and category in .Net 1.1 with Windows 2003 and XP as our operating systems. We use the following code to do this
if (PerformanceCounterCategory.Exists(categoryName)
PerformanceCounterCategory.Delete(categoryName)
CounterCreationData ccd = new CounterCreationData(counterName, counterHelp, PerformanceCounterType.RateOfCountsPerSecond32)
CounterCreationDataCollection ccdc = new CounterCreationDataCollection()
ccdc.Add(ccd)
PerformanceCounterCategory perfCategory = PerformanceCounterCategory.Create(categoryName, categoryHelp, ccdc)
OurLibrary.Error.AssertThrow(perfCategory.CounterExists(counterName), String.Format("Expected \"{0}\" counter to exist.", counterName))
PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, false)
We get a "Category does not exist" InvalidOperationException when we assert that the counter exists. perfCategory != null at this time. The PerformanceCounterCategory.Create does NOT throw. We have tried many permutations of calls to try to get this to work, but it always throws. The odd thing is that the category and counter are actually created in the perfmon utility. We can see them from .net too, but not in the process that created them. We have tried this same code on Windows 2000 boxes and it works correctly. What is the problem with the Windows 2003 and XP operating systems that cause this to fail? We have searched the newsgroups and have not seen any explanations and very few instances of this problem. Are we the only ones using the .net performance counters
Thanks
Frank
if (PerformanceCounterCategory.Exists(categoryName)
PerformanceCounterCategory.Delete(categoryName)
CounterCreationData ccd = new CounterCreationData(counterName, counterHelp, PerformanceCounterType.RateOfCountsPerSecond32)
CounterCreationDataCollection ccdc = new CounterCreationDataCollection()
ccdc.Add(ccd)
PerformanceCounterCategory perfCategory = PerformanceCounterCategory.Create(categoryName, categoryHelp, ccdc)
OurLibrary.Error.AssertThrow(perfCategory.CounterExists(counterName), String.Format("Expected \"{0}\" counter to exist.", counterName))
PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, false)
We get a "Category does not exist" InvalidOperationException when we assert that the counter exists. perfCategory != null at this time. The PerformanceCounterCategory.Create does NOT throw. We have tried many permutations of calls to try to get this to work, but it always throws. The odd thing is that the category and counter are actually created in the perfmon utility. We can see them from .net too, but not in the process that created them. We have tried this same code on Windows 2000 boxes and it works correctly. What is the problem with the Windows 2003 and XP operating systems that cause this to fail? We have searched the newsgroups and have not seen any explanations and very few instances of this problem. Are we the only ones using the .net performance counters
Thanks
Frank