Process Performance Counter Error

This error is coming on application start up. after that the application is terminated.

Answer this question

Process Performance Counter Error

  • juanchoom

    It could also be in your startup form code.

    If there is an error in the Form_Load() event or the sub New() for the class, then there will be no form generated, and the program will exit out.

    Also, if you are declaring variables that use other objects that have a null value will give this error.
    For exmaple...

    CLass Form1
    private MyVar as SomeThing = nothing
    Private MyVar2 as SomeOtherTHing = MyVar.GetOtherThing()
    End class

    In the example above, the form will not load because it tried to create MyVar2 using a null reference to MyVar.

    To avoid this issue, simply set the variables in the form load code...example..

    Class Form1
        private MyVar as SomeThing = nothing
        Private MyVar2 as SomeOtherTHing
           
        public sub form_load(sender as object, e as eventargs) handles form1.load
          MyVar2  = MyVar.GetOtherThing()
        end sub
    End class


    in the example above, you still get an error because myvar2 is being created by a null reference to MyVar.  But doing it this way allows you to catch the error using the debugger stepthrough.



    Dustin.


  • Dmitry_M

    I've seen this error before when during startup the application uses system.diagnostics to check if there is another process running with the same name (i.e. to make sure only 1 copy of the program can run). If you've not got the source of the application, try adding your user to the performance counters user group. Theres some on this, and alternative solutions, if you've the source @ http://weblogs.asp.net/nunitaddin/archive/2004/11/21/267559.aspx

    Cathal

  • ToooM

    Many Thanks. You are right, at startup, there was a check for any existing application instances using the process class. I will apply your solution and I am sure this would help solving the problem of this machine because I don't see any other reasons.
    Thanks again.


  • Process Performance Counter Error