Unprocessed exception: process performance counters disabled
Debugging error:
Unprocessed exception: System. InvalidOperationException: The process performance counter is disabled, so the requested operation cannot be performed.
Solution:
Method 1:
In this case, you only need to fix windows performance counters.
Specific Method: Enter lodctr/r in the running process and press Enter. After running, restart the computer.
Method 2:
Modify registry information
The key value Disable Performance Counters under HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/PerfProc/Performance is set to 0. Restart!
Use C # programming to set the Disable Performance Counters key value to 0"
Using Microsoft. Win32;
Private void Button7_Click (object sender, System. EventArgs e)
{
RegistryKey hklm = Registry. LocalMachine;
RegistryKey software = hklm. OpenSubKey ("SYSTEM // CurrentControlSet // Services // PerfProc", true );
RegistryKey myKey = software. OpenSubKey ("Performance", true );
MyKey. SetValue ("Disable Performance Counters", 0 );
}
The current user is required to be the administrator of the local machine; otherwise, the registry cannot be modified.