This project has moved and is read-only. For the latest updates, please go here.

Use in VB.net

Aug 5, 2012 at 6:36 PM

I all,

I'm Nicolas. I found your library really nice! But I don't know c# and I'd like to use it in a vb.net program.

Could you help me to implement it? What is the conversion in vb.net

Thank you for your help.

Regards.

Nicolas

Aug 15, 2012 at 11:19 AM

 

Imports System.Windows.Forms
Imports System.Threading
Imports CrashReporterDotNET

Namespace CrashReporterTest
	NotInheritable Class Program
		Private Sub New()
		End Sub
		<STAThread>
		Private Shared Sub Main()
			AddHandler Application.ThreadException, AddressOf ApplicationThreadException

			'designer generated code.
		End Sub

		Private Shared Sub ApplicationThreadException(sender As Object, e As ThreadExceptionEventArgs)
			Dim reportCrash = New ReportCrash() With { 
				Key.FromEmail = "Your gmail address", 
				Key.ToEmail = "Email address where you want to send crash report",
				Key.SMTPHost = "smtp.gmail.com", 
				Key.Port = 587, 
				Key.UserName = "Your gmail address", 
				Key.Password = "Your password", 
				Key.EnableSSL = True 
			}

			reportCrash.Send(e.Exception)
		End Sub
	End Class
End Namespace

 

 

I'm not familiar with VB.NET Syntax so i used http://codeconverter.sharpdevelop.net/SnippetConverter.aspx/ . You can try C# to VB.NET converters from below if above code doesn't work.

http://www.carlosag.net/tools/codetranslator/

http://converter.telerik.com/

Feb 5, 2013 at 9:15 AM
Edited Feb 5, 2013 at 9:42 AM
Hi

I am also having trouble trying to use this class with VB.NET.

I have used the code converters and believe that i have correct code - but the exception isnt thrown.
            Dim reportCrash = New ReportCrash() With { _
 .FromEmail = "Your gmail address", _
 .ToEmail = "Email address where you want to send crash report", _
 .SMTPHost = "smtp.gmail.com", _
 .Port = 587, _
 .UserName = "Your gmail address", _
 .Password = "Your password", _
 .EnableSSL = True _
}

            reportCrash.Send(e.Exception)
i have the import - Imports CrashReporterDotNET

But when i do a first compile its like the reference is removed - the CrashReporterDotNET is red underlined

The reference DLL is still listed - but i can re do the Imports CrashReporterDotNET untill the reference is removed and re-added

Any ideas?

UPDATE: It works absolutely fine with the above code with version 1.1 - so it seems there is an issue in v1.2
Mar 4, 2015 at 3:03 PM
Sorry this is over a year old but I was experiencing the same issue and this is the first thing I came across so I assume somebody else facing this issue will find this.
Anyways,
Switching the target framework from ".Net Framework 4 Client Profile" to ".Net Framework 4" fixed the issue.

Noob friendly: to switch your target framework in VS, double click "My Project" in the solution explorer, go to the compile tab and advanced compile options. Target framework is the last option.
Mar 5, 2015 at 5:03 AM
Create a file Program.vb, then replace these code. My project uses these code and works fine.
Imports System.Windows.Forms
Imports System.Threading
Imports CrashReporterDotNET

Namespace YOUR_NAMESPACE_HERE
    NotInheritable Class Program
        <STAThread()>
        Public Shared Sub Main()
            AddHandler Application.ThreadException, AddressOf ApplicationThreadException
            AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomainOnUnhandledException
            Application.EnableVisualStyles()
            Application.Run(New YOUR_STARTUP_SCREEN_HERE)
        End Sub

        Private Shared Sub ApplicationThreadException(sender As Object, e As ThreadExceptionEventArgs)
            ReportCrash(e.Exception)
        End Sub

        Private Shared Sub CurrentDomainOnUnhandledException(sender As Object, e As System.UnhandledExceptionEventArgs)
            ReportCrash(DirectCast(e.ExceptionObject, Exception))
            Environment.Exit(0)
        End Sub

        Private Shared Sub ReportCrash(exception As Exception)
            Dim reportCrash = New ReportCrash() With {
             .FromEmail = "",
             .ToEmail = "",
             .SmtpHost = "",
             .Port = 23,
             .UserName = "",
             .Password = "",
             .EnableSSL = True
            }
            reportCrash.Send(exception)
        End Sub
    End Class
End Namespace
Then switch your target framework to 'net 4' instead of 'net 4 client profile'.
Or you can imports CR.NET project instead of a DLL.