473,506 Members | 16,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching exceptions in other assemblies.

I have an object named DisasterRecovery. The Ctor of this object is this:

private DisasterRecovery()
{
Application.ThreadException+=
new
System.Threading.ThreadExceptionEventHandler(Appli cation_ThreadException);
AppDomain.CurrentDomain.UnhandledException
+=new UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
}

It's private as only 1 static instance of this object is created and
accessed via a singleton.
I would have thought that all exceptions that occur in my program would have
been caught by this object but this doesn't seem to be the case. Exceptions
that occur in different assemblies do not appear to be caught (the
stacktrace shows nothing of this object getting involved at any stage).
Is there a generic method of catching exceptions in other assemblies (like
Application.AssemblyException or something) or is my implementation of this
object incorrect?

Kind Regards

Simon

Aug 27 '06 #1
5 2212
Simon,

why don't you use Application.ThreadException ?

Regards,
Tasos

Simon Tamman wrote:
I have an object named DisasterRecovery. The Ctor of this object is this:

private DisasterRecovery()
{
Application.ThreadException+=
new
System.Threading.ThreadExceptionEventHandler(Appli cation_ThreadException);
AppDomain.CurrentDomain.UnhandledException
+=new UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
}

It's private as only 1 static instance of this object is created and
accessed via a singleton.
I would have thought that all exceptions that occur in my program would have
been caught by this object but this doesn't seem to be the case. Exceptions
that occur in different assemblies do not appear to be caught (the
stacktrace shows nothing of this object getting involved at any stage).
Is there a generic method of catching exceptions in other assemblies (like
Application.AssemblyException or something) or is my implementation of this
object incorrect?

Kind Regards

Simon
Aug 27 '06 #2
I do. It's the first one that is hooked up in the Ctor of the class I
posted.
I handle both Thread and Unhandled.

"Tasos Vogiatzoglou" <tv*****@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Simon,

why don't you use Application.ThreadException ?

Regards,
Tasos

Simon Tamman wrote:
I have an object named DisasterRecovery. The Ctor of this object is
this:

private DisasterRecovery()
{
Application.ThreadException+=
new
System.Threading.ThreadExceptionEventHandler(Appli cation_ThreadException);
AppDomain.CurrentDomain.UnhandledException
+=new
UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
}

It's private as only 1 static instance of this object is created and
accessed via a singleton.
I would have thought that all exceptions that occur in my program would
have
been caught by this object but this doesn't seem to be the case.
Exceptions
that occur in different assemblies do not appear to be caught (the
stacktrace shows nothing of this object getting involved at any stage).
Is there a generic method of catching exceptions in other assemblies
(like
Application.AssemblyException or something) or is my implementation of
this
object incorrect?

Kind Regards

Simon

Aug 27 '06 #3
Simon,

The logical boundary for exceptions being thrown is not an assembly.
Rather, it is the thread that is currently executing.

The code you have will do two things. The first is handle ^unhandled^
exceptions that are thrown in the UI thread (where the static Run method on
the Application class is called).

The second will handle exceptions that are thrown on all threads in the
application which are ^unhandled^.

If there is a try/catch block around the area where exceptions are
thrown, then these methods will not be called. These two methods only
handle unhandled exceptions.

If you find this is not the case, then provide a complete example
showing the behavior.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Tamman" <i_**********************************@NOSPAMhotmai l.com>
wrote in message news:bb******************@newsfe7-win.ntli.net...
>I have an object named DisasterRecovery. The Ctor of this object is this:

private DisasterRecovery()
{
Application.ThreadException+=
new
System.Threading.ThreadExceptionEventHandler(Appli cation_ThreadException);
AppDomain.CurrentDomain.UnhandledException
+=new UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
}

It's private as only 1 static instance of this object is created and
accessed via a singleton.
I would have thought that all exceptions that occur in my program would
have
been caught by this object but this doesn't seem to be the case.
Exceptions
that occur in different assemblies do not appear to be caught (the
stacktrace shows nothing of this object getting involved at any stage).
Is there a generic method of catching exceptions in other assemblies (like
Application.AssemblyException or something) or is my implementation of
this
object incorrect?

Kind Regards

Simon

Aug 27 '06 #4
So, do the other exceptions occur in an other appDomain ?

Simon Tamman wrote:
I do. It's the first one that is hooked up in the Ctor of the class I
posted.
I handle both Thread and Unhandled.

"Tasos Vogiatzoglou" <tv*****@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Simon,

why don't you use Application.ThreadException ?

Regards,
Tasos

Simon Tamman wrote:
I have an object named DisasterRecovery. The Ctor of this object is
this:
>
private DisasterRecovery()
{
Application.ThreadException+=
new
>
System.Threading.ThreadExceptionEventHandler(Appli cation_ThreadException);
AppDomain.CurrentDomain.UnhandledException
+=new
UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
}
>
It's private as only 1 static instance of this object is created and
accessed via a singleton.
I would have thought that all exceptions that occur in my program would
have
been caught by this object but this doesn't seem to be the case.
Exceptions
that occur in different assemblies do not appear to be caught (the
stacktrace shows nothing of this object getting involved at any stage).
Is there a generic method of catching exceptions in other assemblies
(like
Application.AssemblyException or something) or is my implementation of
this
object incorrect?
>
Kind Regards
>
Simon
Aug 27 '06 #5
No, it's neither performing any remoting or handling the exceptions within
it's own little try catches.
It's going to be difficult to provide a complete solution as this is the
combination of several assemblies.
However if it's a suprise to everyone else then this v.probably means that
i'm ballsing this up somehow.
I'll work on trying to replicate this problem is a simple example and repost
it some point later.

Thanks for your help everyone.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:e4**************@TK2MSFTNGP05.phx.gbl...
Simon,

The logical boundary for exceptions being thrown is not an assembly.
Rather, it is the thread that is currently executing.

The code you have will do two things. The first is handle ^unhandled^
exceptions that are thrown in the UI thread (where the static Run method
on
the Application class is called).

The second will handle exceptions that are thrown on all threads in
the
application which are ^unhandled^.

If there is a try/catch block around the area where exceptions are
thrown, then these methods will not be called. These two methods only
handle unhandled exceptions.

If you find this is not the case, then provide a complete example
showing the behavior.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Tamman" <i_**********************************@NOSPAMhotmai l.com>
wrote in message news:bb******************@newsfe7-win.ntli.net...
I have an object named DisasterRecovery. The Ctor of this object is this:

private DisasterRecovery()
{
Application.ThreadException+=
new
System.Threading.ThreadExceptionEventHandler(Appli cation_ThreadException);
AppDomain.CurrentDomain.UnhandledException
+=new
UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
}

It's private as only 1 static instance of this object is created and
accessed via a singleton.
I would have thought that all exceptions that occur in my program would
have
been caught by this object but this doesn't seem to be the case.
Exceptions
that occur in different assemblies do not appear to be caught (the
stacktrace shows nothing of this object getting involved at any stage).
Is there a generic method of catching exceptions in other assemblies
(like
Application.AssemblyException or something) or is my implementation of
this
object incorrect?

Kind Regards

Simon



Aug 27 '06 #6

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

Similar topics

1
2967
by: Rolf | last post by:
I understand a compilation error occurs when a method that throws no exceptions is the only code in a try block. What I don't understnad is why I can specify the catching of an Exception for a...
2
1749
by: Keith Bolton | last post by:
I am handling exceptions currently using try, except. Generally I don't handle specific exceptions and am catching all. Then if an exception occurs, I would like to capture that error string....
26
2854
by: OvErboRed | last post by:
I just read a whole bunch of threads on microsoft.public.dotnet.* regarding checked exceptions (the longest-running of which seems to be <cJQQ9.4419 $j94.834878@news02.tsnz.net>. My personal...
8
1721
by: Adam H. Peterson | last post by:
Hello, I sometimes find myself writing code something like this: try { Derived &d=dynamic_cast<Derived&>(b); d.do_something_complicated(); // etc.... } catch (std::bad_cast) { throw...
7
2314
by: cmay | last post by:
FxCop complains every time I catch System.Exception. I don't see the value in trying to catch every possible exception type (or even figuring out what exceptions can be caught) by a given block...
12
6087
by: Vasco Lohrenscheit | last post by:
Hi, I have a Problem with unmanaged exception. In the debug build it works fine to catch unmanaged c++ exceptions from other dlls with //managed code: try { //the form loads unmanaged dlls...
7
6375
by: Derek Schuff | last post by:
I'm sorry if this is a FAQ or on an easily-accesible "RTFM" style page, but i couldnt find it. I have some code like this: for line in f: toks = line.split() try: if int(toks,16) ==...
4
1839
by: Steve | last post by:
I have read a couple articles online, read my Jesse Liberty book but I am still confused as to just what the best practices are for using exceptions. I keep changing how I'm working with them and...
3
3265
by: john | last post by:
I wrapped some fortran code using F2PY and need to be able to catch fortran runtime errors to run the following: # "grid" is a wrapped fortran module # no runtime errors incurred when run with...
0
7218
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
7307
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,...
0
7370
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...
0
7478
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...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5035
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
3188
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...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.