Reply to thread

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


[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

[/code]


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)


[/code]


Now I dont recall disabling the process performance counter, or whatever it is.


Any ideas on how to fix this?


Back
Top