title: Remote Performance Counters System.InvalidOperationException
body: <p>I've got 2 segments of code who sporadically throw errors. If I run the application locally on the server defined in the server.FullyQualifiedDomainName, I get no errors, never. If I run the application remotely and read the counters via the network, I will get the errors defined below. The errors don't happen all the time. I've read somewhere reading performance counters over a network is kinda shaky... Anyway to get more reliable responses?</p>
  
  <p>Code to read categories:</p>
  
  <pre><code>var windowsCounterCategory = new PerformanceCounterCategory(counterCategory, server.FullyQualifiedDomainName); 
  var serviceGuidsStr = windowsCounterCategory.GetInstanceNames();
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>System.InvalidOperationException: Could not Read Category Index: 8324.
     at System.Diagnostics.CategorySample..ctor(Byte[] data, CategoryEntry entry, PerformanceCounterLib library)
     at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String category)
     at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String machine, String category)
     at System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(String categoryName, String machineName)
     at System.Diagnostics.PerformanceCounterCategory.GetInstanceNames()
  </code></pre>
  
  <p>Code to read counter values:</p>
  
  <pre><code>   using (var perfomanceCounter = new PerformanceCounter(categoryName, counterName, instanceId, Service.Server.FullyQualifiedDomainName))
     {
        var counterValue = perfomanceCounter.RawValue;
        log.Trace("Read counter value " + counterValue.ToString());
        return counterValue;
     }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>System.InvalidOperationException: Could not Read Category Index: 8324.
     at System.Diagnostics.CategorySample..ctor(Byte[] data, CategoryEntry entry, PerformanceCounterLib library)
     at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String category)
     at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String machine, String category)
     at System.Diagnostics.PerformanceCounter.NextSample()
     at System.Diagnostics.PerformanceCounter.get_RawValue()
  </code></pre>