The following is the code I use to prevent multiple instances of my app. Its the same code I used from a previous thread on this forum
Now the thing is, this all used to work up until last night. Now whenever I compile my app I get the following error message
An unhandled exception of type 'System.InvalidOperationException' occurred in system.dll
Additional information: Process performance counter is disabled, so the requested operation cannot be performed.
This refers to this line
Now I don't recall disabling the process performance counter, or whatever it is.
Any ideas on how to fix this?
Code:
Public Class Initialise
Shared Sub Main()
' Prevent Multiple Instances of the Application
Dim appProcesses As Process()
appProcesses = Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)
If appProcesses.Length > 1 Then
Application.Exit()
Else
Dim formMain = New frmMain()
Application.Run(formMain)
End If
End Sub
End Class
Now the thing is, this all used to work up until last night. Now whenever I compile my app I get the following error message
An unhandled exception of type 'System.InvalidOperationException' occurred in system.dll
Additional information: Process performance counter is disabled, so the requested operation cannot be performed.
This refers to this line
Code:
appProcesses = Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)
Now I don't recall disabling the process performance counter, or whatever it is.
Any ideas on how to fix this?