I'm using an external C library in my program coded in C++/CLI with the .NET framework 4. Sometimes the lib crashes and I get the message:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory.
So I tried to handle it with a try/catch block:
try
{
Init(); //< lib call which sometimes crashes
}
catch (Exception^ e)
{
// handle the error
}
But the exception remains uncaught: my program crashes before entering the catch block.
How can I handle this exception to prevent my program from crashing?