I have a performance counter category. The counters in this category may change for my next release so when the program starts, I want to check if the category exists and it is the correct version - if not, create the new category. I can do this by storing a GUID in the help string but this is obviously smelly. Is it possible to do this more cleanly with the .NET API?
Existing smelly version...
if (PerformanceCounterCategory.Exists(CATEGORY_NAME))
{
PerformanceCounterCategory c = new PerformanceCounterCategory(CATEGORY_NAME);
if (c.CategoryHelp != CATEGORY_VERSION)
{
PerformanceCounterCategory.Delete(CATEGORY_NAME);
}
}
if (!PerformanceCounterCategory.Exists(CATEGORY_NAME))
{
// Create category
}