I'm working on a C# WPF application. I'm using a DLL (not developed by me). I'm using it like this (simplified):
try
{
Bitmap bmp = new Bitmap(filePath);
// Use the DLL
var worker = theDLL.loadImage(bmp);
status state = worker.start();
if (state = theDLL.sta.OK)
{
return "OK"
}
else
{
state = worker.tryOtherMethod();
}
}
catch (Exception e)
{
// Do something with e
}
Sometimes (not always) I have a Unhandled exception. This exception is not catch and my application crash :
An invalid parameter was passed to a function that considers invalid parameters fatal.
I saw that this exception comes from C++ code but i'm unable to catch it (even with AppDomain.CurrentDomain.UnhandledException
or Dispatcher.UnhandledException
).
How can I prevent the crash ?
Edit:
I've try to catch the exception with catch
alone and catch (Win32Exception e)
but both didn't solve my problem.
I still have this error :