469,590 Members | 2,312 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,590 developers. It's quick & easy.

Error handling not kicking-in when running exe

Hi,

I have error handling in place throughout my application. I also start the
application wrapped in error handling code to catch any unexpected
exceptions (i.e. exceptions that occur where I haven't placed error handling
code).

When I run my app from the IDE, the unhandled errors are caught by the error
handling code in my Sub Main routine and the error details are logged to a
text file and optionally e-mailed to me for follow-up.

However, when I run the app as an EXE (i.e. running the executable - not
from the IDE) - this error handling does not kick-in. Instead, I the default
..NET error message box is displayed (and the error is not logged).

Any idea why this would be happening? Note, I've noticed the same behaviour
when compiling in both "Release" and "Debug" mode.

Here is the part of my Sub Main that traps all other unexpected errors in
the application:
If gblnAuthenticated Then

Try
Application.Run(New frmMain)
Catch ex As Exception
Dim errInfo As String
errInfo = "Source: " + ex.Source.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Message: " + ex.Message.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Target: " + ex.TargetSite.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Stack Trace: " + vbCrLf
errInfo += ex.StackTrace.ToString + vbCrLf
'show form advising user that an unexpected error has occured
Dim frmErr As New frmError
frmErr.ShowDialog()

Try
'call function to log and E-Mail error details to LDS
clsGeneral.fnLogError(errInfo, gblnAutoSendErrorReports)
Catch e As Exception
'if an error occurs while logging the error - just ignore it
End Try
Finally
Application.Exit()
End Try

End If
Nov 20 '05 #1
4 1658
Al,

Does frmMain have any error handlers? If so do you rethrow the errors?

Dan
"Al Williams" <al@luckydogsystems.com> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have error handling in place throughout my application. I also start the
application wrapped in error handling code to catch any unexpected
exceptions (i.e. exceptions that occur where I haven't placed error handling code).

When I run my app from the IDE, the unhandled errors are caught by the error handling code in my Sub Main routine and the error details are logged to a
text file and optionally e-mailed to me for follow-up.

However, when I run the app as an EXE (i.e. running the executable - not
from the IDE) - this error handling does not kick-in. Instead, I the default .NET error message box is displayed (and the error is not logged).

Any idea why this would be happening? Note, I've noticed the same behaviour when compiling in both "Release" and "Debug" mode.

Here is the part of my Sub Main that traps all other unexpected errors in
the application:
If gblnAuthenticated Then

Try
Application.Run(New frmMain)
Catch ex As Exception
Dim errInfo As String
errInfo = "Source: " + ex.Source.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Message: " + ex.Message.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Target: " + ex.TargetSite.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Stack Trace: " + vbCrLf
errInfo += ex.StackTrace.ToString + vbCrLf
'show form advising user that an unexpected error has occured
Dim frmErr As New frmError
frmErr.ShowDialog()

Try
'call function to log and E-Mail error details to LDS
clsGeneral.fnLogError(errInfo, gblnAutoSendErrorReports)
Catch e As Exception
'if an error occurs while logging the error - just ignore it
End Try
Finally
Application.Exit()
End Try

End If

Nov 20 '05 #2
No, frmMain does not have any error handling. Basically frmMain has a menu
and toolbar and doesn't do all that much.

However, I have extensive error handling in many of the child forms - but
not ALL the code is encased in "Try..Catch .. End Try" statements.

For these types of unexpected errors, I want the error to "bubble" back up
to SubMain so that the error can be logged and the app shut-down. Like I
said, when running my app from the IDE, this works as expected. But when
running the EXE, I get the default .NET error dialog - which I don't want.

It's probably some obscure setting I haven't configured correctly ...


"solex" <so***@nowhere.com> wrote in message
news:ew**************@TK2MSFTNGP09.phx.gbl...
Al,

Does frmMain have any error handlers? If so do you rethrow the errors?

Dan
"Al Williams" <al@luckydogsystems.com> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected
exceptions (i.e. exceptions that occur where I haven't placed error

handling
code).

When I run my app from the IDE, the unhandled errors are caught by the

error
handling code in my Sub Main routine and the error details are logged to a text file and optionally e-mailed to me for follow-up.

However, when I run the app as an EXE (i.e. running the executable - not
from the IDE) - this error handling does not kick-in. Instead, I the

default
.NET error message box is displayed (and the error is not logged).

Any idea why this would be happening? Note, I've noticed the same

behaviour
when compiling in both "Release" and "Debug" mode.

Here is the part of my Sub Main that traps all other unexpected errors in the application:
If gblnAuthenticated Then

Try
Application.Run(New frmMain)
Catch ex As Exception
Dim errInfo As String
errInfo = "Source: " + ex.Source.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Message: " + ex.Message.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Target: " + ex.TargetSite.ToString + vbCrLf
errInfo += vbCrLf
errInfo += "Stack Trace: " + vbCrLf
errInfo += ex.StackTrace.ToString + vbCrLf
'show form advising user that an unexpected error has occured
Dim frmErr As New frmError
frmErr.ShowDialog()

Try
'call function to log and E-Mail error details to LDS
clsGeneral.fnLogError(errInfo, gblnAutoSendErrorReports)
Catch e As Exception
'if an error occurs while logging the error - just ignore it
End Try
Finally
Application.Exit()
End Try

End If


Nov 20 '05 #3
* "Al Williams" <al@luckydogsystems.com> scripsit:
I have error handling in place throughout my application. I also start the
application wrapped in error handling code to catch any unexpected
exceptions (i.e. exceptions that occur where I haven't placed error handling
code).


Add a handler for 'ThreadException'. More info:

<http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformsapplicationclassthreadexcep tiontopic.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Thanks for the info. Any idea why my existing error handling code works one
way when running from the IDE and differently when running from an EXE?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:#f**************@TK2MSFTNGP12.phx.gbl...
* "Al Williams" <al@luckydogsystems.com> scripsit:
I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected
exceptions (i.e. exceptions that occur where I haven't placed error handling code).
Add a handler for 'ThreadException'. More info:

<http://msdn.microsoft.com/library/en...mwindowsformsa
pplicationclassthreadexceptiontopic.asp>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Christian Christmann | last post: by
5 posts views Thread by tiger79 | last post: by
5 posts views Thread by OHM | last post: by
3 posts views Thread by dgiagio | last post: by
4 posts views Thread by Eugene Anthony | last post: by
1 post views Thread by solomon_13000 | last post: by
16 posts views Thread by john6630 | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.