472,805 Members | 1,049 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

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 1836
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
4
by: John Baker | last post by:
Hi: I have a MACRO and as one step in it I am opening a form, which is based on a query. The query calls for entry of a portion of an associates name as the selection criteria for records. Using...
5
by: tiger79 | last post by:
Hello, I'd like to know what the C# counterpart is for the VB On Error statement ? My VB code looks like this : On Error GoTo ErrGetItem plain simple ud say, but I need to "translate" it into...
5
by: OHM | last post by:
Hi everyone, I have a problem with error handling and wondered if anyone has managed to implement a global exception handling model. Is it possible to ensure that you see all exceptions before...
3
by: dgiagio | last post by:
Hi, I'm creating a SMTP application and I would like to hear opinions about error handling. Currently there are two functions that communicate with the remote peer: ssize_t...
1
by: ss | last post by:
Hi, Could anyone tell me like, how do i do centralized Error Handling, What are all the things I need to take care while Error Handling? How Can I have my own messages instead of system...
4
by: Eugene Anthony | last post by:
One problem with the code bellow is after this code conn.qDupUser p1,rs I added: set rs = nothing to test the error handling capability.
1
by: solomon_13000 | last post by:
I inserted an error handling code for the code bellow. What happen is the page is taking a long time to load. Upon loading it takes me to "page not found" of microsoft internet explorer. How do I...
94
by: Chad | last post by:
On to top of page 163 in the book "The C Programming Langauge" by K & R, they have the following: char *strdup(char *s) { char *p; p=(char *)malloc(strlen(s)+1); if( p != NULL) strcpy(p,s):...
16
by: john6630 | last post by:
Coming from the .Net world, I am used to the try...catch...finally approach to error handling. And PHP 5 now supports this approach. But I am not clear what happens to unhandled errors/exceptioins?...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.