MATLAB: Less Offensive Exception Handling

exceptionhandlingMATLABnet

Hello! We are developing a .NET WPF application which is working with MATLAB R2015b in a toolchain. We implemented (in our application) a global exception handler for logging the error. It works, if we start our application without MATLAB. But this routine is never called, because MATLAB catch the exception bevore this global routine handler got the exception.
Is there a way to change it (so at least we can see/log the error)?

Best Answer

Correction: The initialization of the handler is placed in App.xaml.cs was wrong. Better is to place it in the "Builder"-class, which return an instance to the Window. I solved the problem by changing the kind of initialization:
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
instead of
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(DispatcherUnhandledException);
And the method:
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
//Do some things
}