B
Blasting Cap
I'm trying to convert a 1.1 app to 2.0, and keep finding one thing after
another that either Framework 2.0 or Visual Studio 2005 doesn't like.
Now this -
In the global.asax, code that has been running for nearly 4 years now is
giving me a problem. The code is supposed to give the user a "clean"
page with a login link on it and send an email to me when an app blows
up. It also is supposed to write to the event log too.
This is the code:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim Message As String = "\n\nURL:\n http://localhost/" &
Request.Path _
& "\n\nMESSAGE:\n "
& Server.GetLastError().Message _
& "\n\nSTACK
TRACE:\n" & Server.GetLastError().StackTrace
' Create event log if it does not exist
'Message = Server.GetLastError().ToString
Dim LogName As String = "Application"
If (Not EventLog.SourceExists(LogName)) Then
EventLog.CreateEventSource(LogName, LogName)
End If
' Insert into event log
Dim Log As New EventLog
Log.Source = LogName
Log.WriteEntry(Message, EventLogEntryType.Error)
Dim mail As New MailMessage
Dim sTemp As String = Replace(Session("UserName"), " ", ".")
sTemp = sTemp & "@mycompany.com"
mail.From = New MailAddress(sTemp)
mail.To.Add("(e-mail address removed)")
mail.Subject = "mycompany.com Site Error"
mail.Body = Request.Path & " " & Server.GetLastError().ToString
mail.IsBodyHtml = True
Dim smtp As New SmtpClient
smtp.Send(mail)
End Sub
The statement that generates the error is the firs one - the dim Message
as String.
The error is:
"HTTPException was unhandled by user code"
"Request is not available in this context"
If I do a quickwatch on the Server.GetLastError().Message, it returns:
"Exception from HRESULT: 0x800A0035 (CTL_E_FILENOTFOUND)"
The error appears to occur when my web app looks at the server (the www
external name), on which we have challenge/response set on, for a
graphic that I use on the page. I've stepped thru the code on the page,
and it only goes to the Application_error step in Global.asax when the
page tries to display the first of the two graphics that are on the www
external name. It doesn't occur anywhere else.
This code has been functioning on 1.1 framework & Visual Studio 2003 for
several years without a hitch, and had previously been tested by me on
this box and another one without a problem.
What gives with this new message? Why is it picking this error to give
me a problem with?
Any ideas, suggestions appreciated.
BC
another that either Framework 2.0 or Visual Studio 2005 doesn't like.
Now this -
In the global.asax, code that has been running for nearly 4 years now is
giving me a problem. The code is supposed to give the user a "clean"
page with a login link on it and send an email to me when an app blows
up. It also is supposed to write to the event log too.
This is the code:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim Message As String = "\n\nURL:\n http://localhost/" &
Request.Path _
& "\n\nMESSAGE:\n "
& Server.GetLastError().Message _
& "\n\nSTACK
TRACE:\n" & Server.GetLastError().StackTrace
' Create event log if it does not exist
'Message = Server.GetLastError().ToString
Dim LogName As String = "Application"
If (Not EventLog.SourceExists(LogName)) Then
EventLog.CreateEventSource(LogName, LogName)
End If
' Insert into event log
Dim Log As New EventLog
Log.Source = LogName
Log.WriteEntry(Message, EventLogEntryType.Error)
Dim mail As New MailMessage
Dim sTemp As String = Replace(Session("UserName"), " ", ".")
sTemp = sTemp & "@mycompany.com"
mail.From = New MailAddress(sTemp)
mail.To.Add("(e-mail address removed)")
mail.Subject = "mycompany.com Site Error"
mail.Body = Request.Path & " " & Server.GetLastError().ToString
mail.IsBodyHtml = True
Dim smtp As New SmtpClient
smtp.Send(mail)
End Sub
The statement that generates the error is the firs one - the dim Message
as String.
The error is:
"HTTPException was unhandled by user code"
"Request is not available in this context"
If I do a quickwatch on the Server.GetLastError().Message, it returns:
"Exception from HRESULT: 0x800A0035 (CTL_E_FILENOTFOUND)"
The error appears to occur when my web app looks at the server (the www
external name), on which we have challenge/response set on, for a
graphic that I use on the page. I've stepped thru the code on the page,
and it only goes to the Application_error step in Global.asax when the
page tries to display the first of the two graphics that are on the www
external name. It doesn't occur anywhere else.
This code has been functioning on 1.1 framework & Visual Studio 2003 for
several years without a hitch, and had previously been tested by me on
this box and another one without a problem.
What gives with this new message? Why is it picking this error to give
me a problem with?
Any ideas, suggestions appreciated.
BC