title: Can't get the CPU Usage in C# using PerformanceCounter - System.FormatException
body: <p>I always used this simple code (from <a href="https://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c">#278071</a>) to get CPU usage:</p>
  
  <pre><code>var cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
  
  public string getCurrentCpuUsage() {
          return cpuCounter.NextValue()+"%";
  }
  </code></pre>
  
  <p>It worked perfectly for years. But it's not working after upgrade. I'm using Windows 10 now and cpuCounter.NextValue throws <strong>System.FormatException</strong>: Input string was not in a correct format.</p>
  
  <p>What's wrong? Is it because of Windows 10? Or it's because of my new CPU - Xeon E5-2683? How can I get the CPU usage?</p>
  
  <p><strong>upd:</strong>
  System.FormatException is thrown when I'm using .NET Framework 3.5. I switched to .NET Framework 4.5 and now it throws <strong>InvalidOperationException</strong>: Cannot load Counter Name data because an invalid index '' was read from the registry.</p>