PsychoCoder
Programmer
OK,
I have created an error reporting class file for the application Im working on, in it I have the following procedure which emails both administrators of the error. This isnt called unless theres an error in a process on one of the pages. THe procedure goes as follows:
When this is called on one of my pages I get the following error:
This error doesnt occur on every page that the class is called, so far this is the only page this has happened on. any ideas anyone?
PS: The bold items are the real values, just removed for security
I have created an error reporting class file for the application Im working on, in it I have the following procedure which emails both administrators of the error. This isnt called unless theres an error in a process on one of the pages. THe procedure goes as follows:
Code:
Public Shared Sub SendErrorNotification(ByVal user As Integer, ByVal page As String, ByVal process As String, ByVal err As Integer, ByVal message As String, ByVal type As String)
With oMail
.To.Add(New Net.Mail.MailAddress("[b]email_address_1[/b]", "[b]To Name 1[/b]"))
.To.Add(New Net.Mail.MailAddress("[b]email_address_2[/b]", "[b]To Name 2[/b]"))
.From = New Net.Mail.MailAddress("[b]from email[/b]", "[b]From name[/b]")
.Subject = "Error in process: " & process & " on page: " & page
.Body = [b]To Name 1[/b] & [b]To Name 2[/b],<br> There has been an error in the process " & process & " on page " & page & ".<BR>"
.Body &= "The error information is as follows:<BR>-------------------------------------------------------------------------------<BR>"
.Body &= "User: " & user & "<BR>"
.Body &= "Error Code: " & err & "<BR>"
.Body &= "Error Type: " & type & "<BR>"
.Body &= "Error Message: " & message & "<BR>"
.Body &= "Date: " & DateTime.Now.ToShortDateString & "<BR>"
.Body &= " Time: " & DateTime.Now.ToShortTimeString & "<BR>"
.Body &= "-------------------------------------------------------------------------------<BR>"
.IsBodyHtml = True
End With
Dim Client As New Net.Mail.SmtpClient()
Client.Host = "[b]server_name[/b]"
Client.Send(oMail)
oMail = Nothing
Client = Nothing
End Sub
When this is called on one of my pages I get the following error:
Code:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 72: Public Shared Sub SendErrorNotification(ByVal user As Integer, ByVal page As String, ByVal process As String, ByVal err As Integer, ByVal message As String, ByVal type As String)
Line 73: With oMail
Line 74: .To.Add(New Net.Mail.MailAddress("[b]email[/b]", "[b]name[/b]"))
Line 75: .To.Add(New Net.Mail.MailAddress("[b]email[/b]", "[b]name[/b]"))
Line 76: .From = New Net.Mail.MailAddress("[b]email[/b]", "[b]name[/b]")
This error doesnt occur on every page that the class is called, so far this is the only page this has happened on. any ideas anyone?
PS: The bold items are the real values, just removed for security