Finding origin assembly of an exception

Finding origin assembly of an exception

am 08.11.2007 18:11:42 von kerplunkwhoops

Hello

I have created a seperate class library for handling exceptions ie
logging, alerts etc.

This class library can be referenced by any number of other assemblies
which pass any exceptions to the handler library in
Application.ThreadException and
AppDomain.CurrentDomain.UnhandledException.

Is there any way to determine the assembly where the exception
originated, or will I need to explicitly pass the assembly information
to the handler?

Microsofts Application Blocks has an exception handler that uses
Assembly.GetExecutingAssembly() to get assembly information, but this
simply returns the handler class library, not the exception
originator.

Thanks

Paul

Re: Finding origin assembly of an exception

am 09.11.2007 22:36:33 von mattias.dont.want.spam

>Is there any way to determine the assembly where the exception
>originated, or will I need to explicitly pass the assembly information
>to the handler?

Check yourException.TargetSite.DeclaringType.Assembly


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.