Nick W.
Nick W.

Reputation: 1090

Catching runtime exceptions in IoC container

I'm using Spring.NET with Caliburn 2 and getting some exceptions from these frameworks at runtime (e.g. NoSuchObjectDefinitionException and UnsatisfiedDependencyException in Spring.NET, NullReferenceException in Caliburn).

These exceptions are being raised after my App.xaml.cs InitializeComponent() method has finished, meaning (as far as I am aware) there is no line in my code specifically causing the error, and therefore nothing to wrap in a try-catch. Almost certainly I've misconfigured Spring or Caliburn somewhere, but I would really like whatever clues these exceptions contain in order to figure it out.

Is there some way to catch and inspect exceptions generated from third-party framework code at runtime?

Upvotes: 5

Views: 406

Answers (1)

Femaref
Femaref

Reputation: 61477

You can the use

Application.DispatcherUnhandledException
AppDomain.CurrentDomain.UnhandledException

events.

This should catch all exceptions you can't wrap with try/catch yourself.

Upvotes: 4

Related Questions