I have a WinForms application which dynamically loads an assembly generated by MatLab (3rd Party). Currently, I encountered the problem that an error (maybe exception) somewhere in the MatLab code structure, cannot be caught on C# side. And by this, the whole application goes down...
What I tried is:
- Try/Catch Block (even with no exception type, as described here: https://stackoverflow.com/a/150675/3809520)
- HandleProcessCorruptedStateExceptions attribute, as described here: https://stackoverflow.com/a/10517244/3809520)
Is there anything that I could do more?
Thanks!
Edit: Application is using .NET 4.5 Framework
Edit2:
Tried Application.ThreadException
event together with Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException)
and AppDomain.UnhandledExceptions
event as proposed in comment - both events not triggered.
Edit3: I will try to nail it down to a minimal example, the questions was intended to be more generic, like: what else can be done on my code side to catch exceptions