Solved

.NET application just closing randomly, event viewer shows P9 system.nullreferenceexception

Posted on 2008-10-19
7
844 Views
Last Modified: 2008-11-02
I've been having random crashes in my application lately... I can't seem to pinpoint what is going on. The application just closes.

Event Viewer shows:

EventType clr20r3, P1 y3stand.exe, P2 1.0.0.0, P3 48f82eb0, P4 system, P5 2.0.0.0, P6 471ebf0d, P7 2c3a, P8 c, P9 system.nullreferenceexception, P10 NIL.

I've added this to the main Form

    Public Event UnhandledException As UnhandledExceptionEventHandler

    Sub Main()
        Dim currentDomain As AppDomain = AppDomain.CurrentDomain
        AddHandler currentDomain.UnhandledException, AddressOf MyHandler
    End Sub

    Sub MyHandler(ByVal sender As Object, ByVal args As UnhandledExceptionEventArgs)
        Dim e As Exception = DirectCast(args.ExceptionObject, Exception)
        Debug.WriteLine("MyHandler caught : " + e.Message)
        LogError2("MyHandler caught : " + e.Message)
    End Sub


LogError2 function opens an httprequest to record the message in my database with a tiemstamp, etc.


Apparently this unhandledexception wasn't caught by this handler... did I do something wrong? How do you guys suggest I locate / handle this?


0
Comment
Question by:mcainc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
7 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 22753790
If you are using .Net 2.0, you can use the Application events, which contains an UnhandledException event.

Go to your project properties, then in the "Application" tab, click the "View Application Events" button, then paste the below routine in the MyApplication class.

Wayne
        Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
            Debug.WriteLine("MyHandler caught : " + e.Exception.Message)
            LogError2("MyHandler caught : " + e.Exception.Message)
        End Sub

Open in new window

0
 

Author Comment

by:mcainc
ID: 22753805
awesome, thanks i will try this
0
 

Author Comment

by:mcainc
ID: 22754521
hmm, it still didn't catch it... the app just closed

event viewer showed this:

EventType clr20r3, P1 y3stand.exe, P2 1.0.0.0, P3 48fba928, P4 system, P5 2.0.0.0, P6 471ebf0d, P7 2c3a, P8 c, P9 system.nullreferenceexception, P10 NIL.

there is some threading in the application, would this cause it?

there is also an external control / dll that is used occasionally, i'm starting to think this might be it, what do you think?

Delcare Function EncryptGrp Lib "C:\EncGrp3.dll" .....

is there any way to catch / contain these errors?

0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:mcainc
ID: 22754592
is there a decent free debugging software i can use to load the process & keep an eye on it?

0
 
LVL 1

Expert Comment

by:Abh4IT
ID: 22756541
Not able to identify when it crashes. Is it during inactivity or during some activity it crashes. If it sits idle and crashes, do you have any timer based implementation that restarts at some particular intervals. Can you be a litte more detail of what and how it is happening, so that we can help? Somewhere in your code a codepart is hit with an object coming as null. Before you operate on certain objects you should have the check if object is null. for example fileobjects..
0
 

Author Comment

by:mcainc
ID: 22760551
I do believe it is happening somewhere in a timer

I'll try to add some object checking as you suggested
0
 

Author Comment

by:mcainc
ID: 22764761
im doing some testing now after adding some checking for all of the objects

is there a reason that application events didn't catch this error though? i was under the impression that it would catch any unhanded exceptions
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
call a controller action method from Global.asax in asp.net 1 28
Please explain purpose of GZIP 4 58
Install IIS7.5 on Windows Sever 2012 R2 4 31
c#, case, if 4 18
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question