473,471 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Global error catching...

Stu
Hi,

Is there any way to catch every exception raised in an application (in order
to write it to a log file for example).

Thanks in advance,

Stu
Nov 19 '05 #1
3 2108
Here is what I use quite successfully...

1. The very first line of code to run should be:

AddHandler Application.ThreadException, AddressOf
modGlobal.OnThreadException

2. In a standard module called modGlobal, add a method called
OnThreadException that looks like this:

Public Sub OnThreadException(byval sender as object, byval t as
System.Threading.ThreadExceptionEventArgs)

dim exp as Exception = t.exception
dim strMsg as string
strMsg = String.Format("We're sorry, an untrapper error occurred.{0}The
error messaged was:{0}{1}",vbcrlf,exp.ToString)
msgbox(strMsg)
End Sub

--
**************************************
Andrés Becerra
Pennsylvania, USA
Email not posted due to email stealing A**H***S that poll newsgroups.
**************************************
"Stu" <st****@ntpcl.uk.com> wrote in message
news:#R*************@TK2MSFTNGP10.phx.gbl...
Hi,

Is there any way to catch every exception raised in an application (in order to write it to a log file for example).

Thanks in advance,

Stu

Nov 19 '05 #2
"Stu" <st****@ntpcl.uk.com> wrote in message
news:%2*******************@TK2MSFTNGP10.phx.gbl...
Hi,

Is there any way to catch every exception raised in an application (in order to write it to a log file for example).


MS has released the so-called Application Block for exceptions. You can find
it here:
http://search.microsoft.com/gomsuri....ml/emab-rm.asp

This may be more than your looking for, and by default exceptions "bubble
up", meaning that if you have one Try...Catch block around your entry point
code, it will catch ALL exceptions for the entire application (granted they
are not caught earlier at a deeper level of execution).

Good Luck,
Jeremy

Nov 19 '05 #3
Hello,

"Stu" <st****@ntpcl.uk.com> schrieb:
Is there any way to catch every exception raised in an
application (in order to write it to a log file for example).


Even handled exceptions?!

For Windows Forms (ThreadException, ...):

http://msdn.microsoft.com/library/en...ptiontopic.asp

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kyle Root | last post by:
I'm writing a little program that compares two versions and tells you whether you are upgrading, downgrading, or it's the same version. Unfortunately, I haven't gotten very far, in fact I'm at a...
15
by: MackS | last post by:
The system I am working on supports a subset of C99, among which "standard-compliant VLAs". I've already learnt that VLAs can't have global scope. My question is whether I can safely declare a...
28
by: robert | last post by:
In very rare cases a program crashes (hard to reproduce) : * several threads work on an object tree with dict's etc. in it. Items are added, deleted, iteration over .keys() ... ). The threads are...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
1
by: Groove | last post by:
Hey guys - I'm sure this is a commonly asked question but here goes. I'm trying to catch the error in my global.asax file and redirect to a error page which will email me the actual error upon...
1
by: vikram | last post by:
I want to provide a custom erro handler for my application. henc I decided to handle all error in Global.asax application_error event and then process the error respectively. Is there any problem...
0
by: jefftheman812 | last post by:
I would like to use a global error handler via the web config file. Setting the error page is easy but I seem to be having issues catching the error in my customized page. Here is the offending...
2
by: Richard Coltrane | last post by:
Hi there, Ive just implemented some application level exception handling in ASP.Net 2.0. I deliberately set up a null reference error in my code to see how this would be handled. Sure enough...
5
by: tech.rawsteak | last post by:
I have a function that retrieves a user's login name from their workstation and looks it up on an employee table to return their full name (ie: jsmith -John Smith). Their full name is then...
0
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,...
0
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...
0
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
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 ...

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.