Question

I have searched far and wide for recommendations on how to try and capture all errors, but I did not find anything I didn't already try.


This is a Visual Basic .NET (.NET 3.5) application that I inherited recently at work. They have had this problem for awhile where the application will just crash with no error -- the program just closes/disappears.

The application was already handling MyApplication.UnhandledException which wasn't catching the issue. I added a handler for AppDomain.CurrentDomain.UnhandledException to see if that would catch the issue, but no luck and I am handling the fact that System.UnahndledExceptionEventArgs.ExceptionObject may not be of type Exception.

There are no other threads being created and no other AppDomains being created. It seems to crash anywhere between 3-5+ hours of use and is not dependent on the action the user took.

With all that said, is there anything else I can hook into to try and capture these errors? All my expertise revolve around C# so I am not sure if there is anything else I could possibly hook into with VB.NET or if I missed something else.

My other question is: What's the proper way to log errors inside these events? I normally attempt to log to file, however, the existing code and myself quickly trying to capture the unhandled AppDomain exceptions are firing off a MessageBox. As I write this, I can see this possibly as a reason I am not being informed of errors.

Thanks

Update 1

I was finally able to get it to crash for me (not in the IDE) and saw what appeared to be a MessageBox window outline quickly appear and disappear before the contents were drawn. I have modified my unhandled exception handling to log to a file on the user's desktop instead. I guess at this point it is more of a waiting game since I cannot get it to crash in the IDE.

Was it helpful?

Solution

It appears as though my attempts to catch all exceptions were correct. Catching the AppDomain.CurrentDomain.UnhandledException was getting triggered on these crashes. My initial attempt to pop up a message box was flawed. It crashed today after I made changes to log to a file on the user's desktop instead and the error was properly reported.


Incase anyone is curious on the crash -- it appears that I am running out GDI resources due to a third party control. An out of memory exception is being thrown, at random times when a control is initialized. In the case of the error I caught today, it blew up on the constructor of the standard TextBox when opening a form. This coincides with the very small GDI leak I found when running a memory profiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top