0

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:

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

royalTS
  • 603
  • 4
  • 22
  • 6
    Indeed there are exceptions you can´t catch, because there simply is no meaningful way of handling them at all. Best example here is a `StackOverflowException`. However, without seeing any code it´s impossible to guess what exception you may talk about. – MakePeaceGreatAgain Oct 18 '19 at 07:07
  • Did you check event viewer on the machine where you are getting this exception ? It may provide a clue. – Manoj Choudhari Oct 18 '19 at 07:12
  • 1
    As its winforms, you can use application.threadexception, Application.SetUnhandledExceptionMode – BugFinder Oct 18 '19 at 07:21
  • 1
    Please describe in more detail how you're loading the assembly, and show us some of your code. Is there a reason why you're not calling the assembly through interop (native code) instead? – silkfire Oct 18 '19 at 07:22

0 Answers0