Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 18th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. InvalidOperationException when creating PerformanceCounter
  2. namespace TestConsole
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available Bytes");
  9.         }
  10.     }
  11. }
  12.        
  13. Unhandled Exception: System.InvalidOperationException: Category does not exist.
  14.    at System.Diagnostics.PerformanceCounterLib.CounterExists(String machine, String category, String counter)
  15.    at System.Diagnostics.PerformanceCounter.Initialize()
  16.    at System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean
  17. readOnly)
  18.    at System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName)
  19.    at TestConsole.Program.Main(String[] args) in D:ProjektarbeitBachelorarbeitVS2010ProjekteDiagStationControllerTe
  20. stConsoleV1TestConsoleProgram.cs:line 15