473,700 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 gblnAuthenticat ed Then

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

Try
'call function to log and E-Mail error details to LDS
clsGeneral.fnLo gError(errInfo, gblnAutoSendErr orReports)
Catch e As Exception
'if an error occurs while logging the error - just ignore it
End Try
Finally
Application.Exi t()
End Try

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

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

Dan
"Al Williams" <al@luckydogsys tems.com> wrote in message
news:ug******** ******@TK2MSFTN GP09.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 gblnAuthenticat ed Then

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

Try
'call function to log and E-Mail error details to LDS
clsGeneral.fnLo gError(errInfo, gblnAutoSendErr orReports)
Catch e As Exception
'if an error occurs while logging the error - just ignore it
End Try
Finally
Application.Exi t()
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******** ******@TK2MSFTN GP09.phx.gbl...
Al,

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

Dan
"Al Williams" <al@luckydogsys tems.com> wrote in message
news:ug******** ******@TK2MSFTN GP09.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 gblnAuthenticat ed Then

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

Try
'call function to log and E-Mail error details to LDS
clsGeneral.fnLo gError(errInfo, gblnAutoSendErr orReports)
Catch e As Exception
'if an error occurs while logging the error - just ignore it
End Try
Finally
Application.Exi t()
End Try

End If


Nov 20 '05 #3
* "Al Williams" <al@luckydogsys tems.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 'ThreadExceptio n'. More info:

<http://msdn.microsoft. com/library/en-us/cpref/html/frlrfsystemwind owsformsapplica tionclassthread exceptiontopic. 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******** ******@TK2MSFTN GP12.phx.gbl...
* "Al Williams" <al@luckydogsys tems.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 'ThreadExceptio n'. More info:

<http://msdn.microsoft.com/library/en...mwindowsformsa
pplicationclass threadexception topic.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
6678
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 assert could be used to start an interactive debugger automatically. How do I realize that on a Linux machine using gcc?
4
5548
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 the form : Like & "*" The snag is that the box that comes up offers the opportunity to click on "Cancel". When the user clicks on "Cancel" (intending to stop the process) the system appears to close out totally. In other words, there is no...
5
6570
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 C#... Any ideas ???
5
2093
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 it becomes an unhandled exception. This is opposale to putting Try Catches around every statement
3
372
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 smtp_puts(smtp_stream_t *stream, const char *fmt, ...); ssize_t smtp_gets(smtp_stream_t *stream, char *buf, size_t len); Both of them return the number of written bytes to the stream, or -1 if
1
1292
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 generated error message to show it to the end user? regards, bye
4
1898
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
1409
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 solve the problem? <html> <head> <title></title> </head>
94
3219
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): return p;
16
5054
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? Do I define a default error handler as well as do my try/catch? Can I mix error handling with the exceptions? Is one approach better than the other? TIA John
0
8726
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8645
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9075
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4404
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4657
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.