CrashReporter.NET icon indicating copy to clipboard operation
CrashReporter.NET copied to clipboard

VB.NET Example

Open igrebel opened this issue 5 years ago • 2 comments

Hello,

can you show me a little VB.net example? I was trying to include your crashreporter, but have some errors.

Thanks!

igrebel avatar Jan 08 '21 11:01 igrebel

Are you using the binaries from NuGet or the raw code? What is the error you're receiving?

EddieDemon avatar Feb 02 '21 08:02 EddieDemon

Hello,

can you show me a little VB.net example? I was trying to include your crashreporter, but have some errors.

Thanks!

I seem to have gotten CrashReporter.Net to work on VB.Net, see Code Example:

Hope it helps!

Imports System.Threading, CrashReporterDotNET
Public Class Form1
    ''' <summary>
    ''' Main entry point of the Program.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'Listen to Application Crashes and show CrashReporter.Net if one occurrs.
        AddHandler Application.ThreadException, AddressOf ApplicationThreadException
        AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomainOnUnhandledException
    End Sub

    ''' <summary>
    ''' Show CrashReporter.Net for unhandled exceptions.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="unhandledExceptionEventArgs"></param>
    Private Shared Sub CurrentDomainOnUnhandledException(sender As Object, unhandledExceptionEventArgs As UnhandledExceptionEventArgs)
        SendReport(DirectCast(unhandledExceptionEventArgs.ExceptionObject, Exception))
        Environment.[Exit](0)
    End Sub
    
    ''' <summary>
    ''' Show CrashReporter.Net for Application Thread Exceptions.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Shared Sub ApplicationThreadException(sender As Object, e As ThreadExceptionEventArgs)
        SendReport(e.Exception)
    End Sub
    
    ''' <summary>
    ''' Main Sub that calls CrashReporter.Net to send an error report
    ''' Replace [email protected] with your or another Email Address.
    ''' You can hide or show the screenshot Tab by setting ShowScreenshotTab to either True or False.
    ''' If you have a https://drdump.com account, you can set your Application GUID according to your Dr.Dump Application, if not remove the .DrDumpSettings section.
    ''' </summary>
    ''' <param name="exception"></param>
    Public Shared Sub SendReport(exception As Exception)
        Dim reportCrash = New ReportCrash("[email protected]") With {
        .ShowScreenshotTab = True,
        .DoctorDumpSettings = New DoctorDumpSettings With {
            .ApplicationID = New Guid("00000000-0000-0000-0000-000000000000")
            }
        }
        reportCrash.Send(exception)
    End Sub
    
    ''' <summary>
    ''' Your average Button or Code that is crashing. In this case it is a Button throwing an exception.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Throw New ApplicationException("This is an error, as well as a Test for CrashReporter.Net")
    End Sub
End Class

image

PeterStrick avatar Jul 21 '21 20:07 PeterStrick