Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 987
Nick W. Avatar asked Oct 11 '22 09:10

Nick W.


1 Answers

You can the use

Application.DispatcherUnhandledException
AppDomain.CurrentDomain.UnhandledException

events.

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

like image 119
Femaref Avatar answered Oct 15 '22 11:10

Femaref