System.NullReference exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    System.NullReference exception

    Hi All

    I have a windows forms Application (SAM) in vb.net 2008 using .net framework
    V2

    One and only one customer out of 30 customers is getting errors daily where
    they have to close and restart my application, sometimes several times a day

    The customer has XP Home SP2

    The event viewer shows the following although not always in the same
    sequence

    EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5 1.0.0.0,
    P6 48d969a4, P7 5, P8 0, P9 system.nullrefe renceexception, P10 NIL.

    EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
    microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
    system.componen tmodel.win32, P10 NIL.

    EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
    microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
    34ssps20bdj3nj0 wmit5kamzhvglfz cc, P10 NIL.

    Hanging application SAM.exe, version 1.0.0.0, hang module hungapp, version
    0.0.0.0, hang address 0x00000000.

    I am lost as to what may be causing it and like I said it only happens to
    the 1 customer

    Any ideas what it could be and any ideas on how to troubleshoot it further
    to find the exact cause?

    Regards
    Steve



  • Armin Zingler

    #2
    Re: System.NullRefe rence exception

    "Steve" <ga630sf@nospam .nospamschrieb
    Hi All
    >
    I have a windows forms Application (SAM) in vb.net 2008 using .net
    framework V2
    >
    One and only one customer out of 30 customers is getting errors
    daily where they have to close and restart my application, sometimes
    several times a day
    >
    The customer has XP Home SP2
    >
    The event viewer shows the following although not always in the same
    sequence
    >
    EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5
    1.0.0.0, P6 48d969a4, P7 5, P8 0, P9 system.nullrefe renceexception,
    P10 NIL.
    >
    EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
    microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
    system.componen tmodel.win32, P10 NIL.
    >
    EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
    microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
    34ssps20bdj3nj0 wmit5kamzhvglfz cc, P10 NIL.
    >
    Hanging application SAM.exe, version 1.0.0.0, hang module hungapp,
    version 0.0.0.0, hang address 0x00000000.
    >
    I am lost as to what may be causing it and like I said it only
    happens to the 1 customer
    >
    Any ideas what it could be and any ideas on how to troubleshoot it
    further to find the exact cause?

    How does you exception handling code look like?


    Armin

    Comment

    • kimiraikkonen

      #3
      Re: System.NullRefe rence exception

      On Oct 16, 1:53 pm, "Steve" <ga63...@nospam .nospamwrote:
      Hi All
      >
      I have a windows forms Application (SAM) in vb.net 2008 using .net framework
      V2
      >
      One and only one customer out of 30 customers is getting errors daily where
      they have to close and restart my application, sometimes several times a day
      >
      The customer has XP Home SP2
      >
      The event viewer shows the following although not always in the same
      sequence
      >
      EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5 1.0.0.0,
      P6 48d969a4, P7 5, P8 0, P9 system.nullrefe renceexception, P10 NIL.
      >
      EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
      microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
      system.componen tmodel.win32, P10 NIL.
      >
      EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
      microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
      34ssps20bdj3nj0 wmit5kamzhvglfz cc, P10 NIL.
      >
      Hanging application SAM.exe, version 1.0.0.0, hang module hungapp, version
      0.0.0.0, hang address 0x00000000.
      >
      I am lost as to what may be causing it and like I said it only happens to
      the 1 customer
      >
      Any ideas what it could be and any ideas on how to troubleshoot it further
      to find the exact cause?
      >
      Regards
      Steve
      First try to have "try-catch" exception handling blocks as many as
      possible in your project to catch "possible" exceptions, then based on
      your description, make sure you have a exception block in form_load
      and form_formclosed and formClosing events like:

      ' When the form is loaded
      Private Sub Form1_Load(.... .) Handles MyBase.Load

      Try

      ' Do the stuff

      Catch ex As Exception
      Msgbox(ex.Messs age)

      End Try

      End Sub

      ....do the same for form's FormClosing and FormClosed events if your
      application is not console one.

      Additionaly, related to "System.NullRef erence" exception, presumably,
      your variable may have no value assigned to the referenced object
      anylonger as the reason of exception. Or the object is being
      instantianted improperly after app restart.

      Just it was a guess,

      Onur Güzel

      Comment

      • Patrice

        #4
        Re: System.NullRefe rence exception

        The first step would be to have a callstack so that you can see where it
        happens. You could start by adding a global exception handler (if not
        already done) in the appplication that would store somewhere exception
        details to ease further analysis...

        ---
        Patrice

        "Steve" <ga630sf@nospam .nospama écrit dans le message de groupe de
        discussion : uwEjx13LJHA.173 6@TK2MSFTNGP03. phx.gbl...
        Hi All
        >
        I have a windows forms Application (SAM) in vb.net 2008 using .net
        framework V2
        >
        One and only one customer out of 30 customers is getting errors daily
        where they have to close and restart my application, sometimes several
        times a day
        >
        The customer has XP Home SP2
        >
        The event viewer shows the following although not always in the same
        sequence
        >
        EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5
        1.0.0.0, P6 48d969a4, P7 5, P8 0, P9 system.nullrefe renceexception, P10
        NIL.
        >
        EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
        microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
        system.componen tmodel.win32, P10 NIL.
        >
        EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
        microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
        34ssps20bdj3nj0 wmit5kamzhvglfz cc, P10 NIL.
        >
        Hanging application SAM.exe, version 1.0.0.0, hang module hungapp, version
        0.0.0.0, hang address 0x00000000.
        >
        I am lost as to what may be causing it and like I said it only happens to
        the 1 customer
        >
        Any ideas what it could be and any ideas on how to troubleshoot it further
        to find the exact cause?
        >
        Regards
        Steve
        >
        >
        >

        Comment

        • Steve

          #5
          Re: System.NullRefe rence exception

          Hi All

          Thanks for the responses

          I have try/catch blocks in most of my routines

          I also have a code in MyApplication_U nhandledExcepti onroutine, which doesn't
          fire (see below)

          'writes unhandled exceptions to my log file

          mymsgbox(e.Exce ption.Message & vbCr & e.Exception.Inn erException.ToS tring)

          If e.Exception.Mes sage.Length 200 Then

          savetolog("Auto ", e.Exception.Mes sage.Substring( 0, 199))

          Else

          savetolog("Auto ", e.Exception.Mes sage)

          End If

          The screen they get when the error occurs is not the usual .net screen
          showing the error details, but the Microsoft screen with send report / don't
          send buttons

          Not sure if this makes a difference

          Regards

          Steve





          "Steve" <ga630sf@nospam .nospamwrote in message
          news:uwEjx13LJH A.1736@TK2MSFTN GP03.phx.gbl...
          Hi All
          >
          I have a windows forms Application (SAM) in vb.net 2008 using .net
          framework V2
          >
          One and only one customer out of 30 customers is getting errors daily
          where they have to close and restart my application, sometimes several
          times a day
          >
          The customer has XP Home SP2
          >
          The event viewer shows the following although not always in the same
          sequence
          >
          EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5
          1.0.0.0, P6 48d969a4, P7 5, P8 0, P9 system.nullrefe renceexception, P10
          NIL.
          >
          EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
          microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
          system.componen tmodel.win32, P10 NIL.
          >
          EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
          microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
          34ssps20bdj3nj0 wmit5kamzhvglfz cc, P10 NIL.
          >
          Hanging application SAM.exe, version 1.0.0.0, hang module hungapp, version
          0.0.0.0, hang address 0x00000000.
          >
          I am lost as to what may be causing it and like I said it only happens to
          the 1 customer
          >
          Any ideas what it could be and any ideas on how to troubleshoot it further
          to find the exact cause?
          >
          Regards
          Steve
          >
          >
          >

          Comment

          • Family Tree Mike

            #6
            Re: System.NullRefe rence exception

            Just a shot in the dark, but can the user run your app as the administrator
            successfully? Often this can be caused by some assumption of full
            permissions somewhere in code. Things like reading or writing registry keys
            may work 9 out of 10 times (or 29 out of 30 in your case).

            "Steve" <ga630sf@nospam .nospamwrote in message
            news:%23YHSjo9L JHA.3504@TK2MSF TNGP02.phx.gbl. ..
            Hi All
            >
            Thanks for the responses
            >
            I have try/catch blocks in most of my routines
            >
            I also have a code in MyApplication_U nhandledExcepti onroutine, which
            doesn't fire (see below)
            >
            'writes unhandled exceptions to my log file
            >
            mymsgbox(e.Exce ption.Message & vbCr & e.Exception.Inn erException.ToS tring)
            >
            If e.Exception.Mes sage.Length 200 Then
            >
            savetolog("Auto ", e.Exception.Mes sage.Substring( 0, 199))
            >
            Else
            >
            savetolog("Auto ", e.Exception.Mes sage)
            >
            End If
            >
            The screen they get when the error occurs is not the usual .net screen
            showing the error details, but the Microsoft screen with send report /
            don't send buttons
            >
            Not sure if this makes a difference
            >
            Regards
            >
            Steve
            >
            >
            >
            >
            >
            "Steve" <ga630sf@nospam .nospamwrote in message
            news:uwEjx13LJH A.1736@TK2MSFTN GP03.phx.gbl...
            >Hi All
            >>
            >I have a windows forms Application (SAM) in vb.net 2008 using .net
            >framework V2
            >>
            >One and only one customer out of 30 customers is getting errors daily
            >where they have to close and restart my application, sometimes several
            >times a day
            >>
            >The customer has XP Home SP2
            >>
            >The event viewer shows the following although not always in the same
            >sequence
            >>
            >EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5
            >1.0.0.0, P6 48d969a4, P7 5, P8 0, P9 system.nullrefe renceexception, P10
            >NIL.
            >>
            >EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
            >microsoft.visu albasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
            >system.compone ntmodel.win32, P10 NIL.
            >>
            >EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
            >microsoft.visu albasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
            >34ssps20bdj3nj 0wmit5kamzhvglf zcc, P10 NIL.
            >>
            >Hanging application SAM.exe, version 1.0.0.0, hang module hungapp,
            >version 0.0.0.0, hang address 0x00000000.
            >>
            >I am lost as to what may be causing it and like I said it only happens to
            >the 1 customer
            >>
            >Any ideas what it could be and any ideas on how to troubleshoot it
            >further to find the exact cause?
            >>
            >Regards
            >Steve
            >>
            >>
            >>
            >
            >

            Comment

            • Jialiang Ge [MSFT]

              #7
              Re: System.NullRefe rence exception

              Hello Steve,

              If an exception goes unhandled in a .NET 2.0 application, it will use
              Windows Error Reporting to send a report automatically. Although we have
              MyApplication_U nhandledExcepti onroutine in the application (according to
              your code snippet, I think it¡¯s added through the
              Application.Thr eadException event) and add try/catch in most of the
              routines, there is actually another source of UnhandledExcept ion:

              ¡°AppDomain.Unh andledException ¡±

              Application.Thr eadException is used to add the event handler for handling UI
              thread exceptions. AppDomain.Unhan dledException adds the event handler for
              handling non-UI thread exception. In other words, if an exception is thrown
              from a non-UI thread, Application.Thr eadException is not able to capture it,
              and it will go to the ¡°Windows Error Report¡± dialog. In addition, we need
              to call
              Application.Set UnhandledExcept ionMode(Unhandl edExceptionMode .CatchException );
              to set the unhandled exception mode to force all windows form error to go
              through our handler. A typical example is:

              SecurityPermiss ion(SecurityAct ion.Demand, Flags =
              SecurityPermiss ionFlag.Control AppDomain)]
              public static void Main(string[] args)
              {
              // Add the event handler for handling UI thread exceptions to the event.
              Application.Thr eadException += new
              ThreadException EventHandler(Er rorHandlerForm. Form1_UIThreadE xception);

              // Set the unhandled exception mode to force all Windows Forms errors to
              go through
              // our handler.
              Application.Set UnhandledExcept ionMode(Unhandl edExceptionMode .CatchException );

              // Add the event handler for handling non-UI thread exceptions to the
              event.
              AppDomain.Curre ntDomain.Unhand ledException +=
              new
              UnhandledExcept ionEventHandler (CurrentDomain_ UnhandledExcept ion);

              // Runs the application.
              Application.Run (new ErrorHandlerFor m());
              }

              private static void CurrentDomain_U nhandledExcepti on(object sender,
              UnhandledExcept ionEventArgs e)
              {
              try
              {
              Exception ex = (Exception)e.Ex ceptionObject;
              // dump the call stack here

              // Create an EventLog instance and assign its source.
              EventLog myLog = new EventLog();
              myLog.Source = "ThreadExceptio n";
              myLog.WriteEntr y(errorMsg + ex.Message + "\n\nStack Trace:\n" +
              ex.StackTrace);
              }
              catch (Exception exc)
              {
              try
              {
              MessageBox.Show ("Fatal Non-UI Error",
              "Fatal Non-UI Error. Could not write the error to the event
              log. Reason: "
              + exc.Message, MessageBoxButto ns.OK, MessageBoxIcon. Stop);
              }
              finally
              {
              Application.Exi t();
              }
              }
              }

              (See MSDN article:
              http://msdn.microsoft.com/en-us/libr...ptionmode.aspx)

              With the above code, we can dump the call stack of the unhandled exception
              in the exception handler, and see how the exception is thrown.

              Regards,
              Jialiang Ge (jialge@online. microsoft.com, remove ¡®online.¡¯)
              Microsoft Online Community Support

              Delighting our customers is our #1 priority. We welcome your comments and
              suggestions about how we can improve the support we provide to you. Please
              feel free to let my manager know what you think of the level of service
              provided. You can send feedback directly to my manager at:
              msdnmg@microsof t.com.

              =============== =============== =============== =====
              Get notification to my posts through email? Please refer to
              http://msdn.microsoft.com/en-us/subs...#notifications.

              Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
              where an initial response from the community or a Microsoft Support
              Engineer within 1 business day is acceptable. Please note that each follow
              up response may take approximately 2 business days as the support
              professional working with you may need further investigation to reach the
              most efficient resolution. The offering is not appropriate for situations
              that require urgent, real-time or phone-based interactions or complex
              project analysis and dump analysis issues. Issues of this nature are best
              handled working with a dedicated Microsoft Support Engineer by contacting
              Microsoft Customer Support Services (CSS) at
              http://support.microsoft.com/select/...tance&ln=en-us.
              =============== =============== =============== =====
              This posting is provided "AS IS" with no warranties, and confers no rights.

              "Steve" <ga630sf@nospam .nospamwrote in message
              news:uwEjx13LJH A.1736@TK2MSFTN GP03.phx.gbl...
              Hi All
              >
              I have a windows forms Application (SAM) in vb.net 2008 using .net
              framework V2
              >
              One and only one customer out of 30 customers is getting errors daily
              where they have to close and restart my application, sometimes several
              times a day
              >
              The customer has XP Home SP2
              >
              The event viewer shows the following although not always in the same
              sequence
              >
              EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4 sam, P5
              1.0.0.0, P6 48d969a4, P7 5, P8 0, P9 system.nullrefe renceexception, P10
              NIL.
              >
              EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48d969a4, P4
              microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 86, P8 a2, P9
              system.componen tmodel.win32, P10 NIL.
              >
              EventType clr20r3, P1 sam.exe, P2 1.0.0.0, P3 48eea25c, P4
              microsoft.visua lbasic, P5 8.0.0.0, P6 471ee7ea, P7 5e, P8 1e1, P9
              34ssps20bdj3nj0 wmit5kamzhvglfz cc, P10 NIL.
              >
              Hanging application SAM.exe, version 1.0.0.0, hang module hungapp, version
              0.0.0.0, hang address 0x00000000.
              >
              I am lost as to what may be causing it and like I said it only happens to
              the 1 customer
              >
              Any ideas what it could be and any ideas on how to troubleshoot it further
              to find the exact cause?
              >
              Regards
              Steve
              >
              >
              >

              Comment

              Working...