Finding origin assembly of an exception

K

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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top