By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,888 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,888 IT Pros & Developers. It's quick & easy.

Catching exceptions in other assemblies.

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.