473,382 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 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 1898
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?...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.