By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,494 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

Error handling not kicking-in when running exe

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
* "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

P: n/a
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.