Application Failure Detection

I made an application in VB.Net. But some users experience a crash on startup. This “Problem made this program work correctly” with only one “Close program” button. Since the application loads a lot of things, is it possible to find out what caused the problem?

+4
source share
1 answer

If the "Application Frame" is enabled in the project properties, click the "View Applications" button on the "Application" project properties page. Then add an event handler:

Partial Friend Class MyApplication Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException ' ... End Sub End Class 

If you are not using the application framework, you should place a catch try block around your Main method. However, this will only lead to exceptions that occur in the main thread. If your application is multi-threaded, you can handle exceptions from all threads by creating this method:

 Public Sub UnhandledExceptionHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) ' ... End Sub 

And then attach it to the current UnhandledException domain, for example:

 AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionHandler 

This event handler will be called for all unhandled exceptions from anywhere in your domain, regardless of the current thread.

+5
source

Source: https://habr.com/ru/post/1411564/


All Articles