title: Performance counters go missing
body: <p>My problem is that some of the performance counter category seems to go missing sometimes, and I don't understand why.</p>
  
  <p>The code below will throw an exception, like this:</p>
  
  <p>Failed to lookup Performance Category</p>
  
  <blockquote>
    <p>Error Msg: Category does not exist. CategoryName: HP EVA Physical Disk<br>
    Group Category list on target: <br>
    ServiceModelService 4.0.<br>
    bla bla</p>
  </blockquote>
  
  <p>Print out contains a long list of performance counters, but not the one I'm after. If I look in perfmon.exe I can find the missing category once.</p>
  
  <p>I'm using the following code to find the different counters inside a category.</p>
  
  <pre><code>public static string[] GetPerformanceCategory(string CategoryName)
  {
      //Console.WriteLine("CategoryName to Search for: " + CategoryName);
      if (string.IsNullOrEmpty(CategoryName))
          throw new NullReferenceException("CategoryName is empty");
  
      try
      {
          PerformanceCounterCategory perfCat = new PerformanceCounterCategory(CategoryName);
  
          string[] catInstances = perfCat.GetInstanceNames();
          return catInstances;
      }
      catch(Exception Ex)
      {
          StringBuilder ErrorMsg = new StringBuilder();
          ErrorMsg.AppendLine("Failed to lookup Preformance Category");
          ErrorMsg.AppendLine("Error Msg: " + Ex.Message);
          ErrorMsg.AppendLine("CategoryName: " + CategoryName);
          ErrorMsg.AppendLine("Category list on target:");
  
          StringBuilder CatList = new StringBuilder();
          var categories = PerformanceCounterCategory.GetCategories();
          foreach (var Cat in categories)
              CatList.AppendLine(Cat.CategoryName);                
  
          ErrorMsg.AppendLine(CatList.ToString());
  
          Logger.WriteToLog(ErrorMsg.ToString(), EventLogEntryType.Error);
          return null;
      }      
  }
  </code></pre>
  
  <p>The question boils down to, is there some "magic" that can make performance counters disappear?  Or perhaps I need to do something specific?</p>