catching exceptions throm in an imported DLL

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

How do i solve the issue of calling an MFC dll function that throws an
exeption ?
i call the dll from a c# app.

Now i use an empty catch but this way i can't get any more information about
the thrown exception.
Maybe i need to remove the exception from my dll function and replace it
with an error code.

try
{
function_in_an_imported_dll();
}
catch (myexception e)
{
e.showreason();
}



Johan
 
You can layer your Exceptions (from most specific to generic, as shown) to
catch more than one type of exception.

try
{
function_in_an_imported_dll();
}
catch (myexception e)
{
e.showreason();
}
catch ( Exception e)
{
// Use e.ToString()
// In preferred manner.
}
catch
{
// Some other exception.
}
finally
{
// Any cleanup.
}

Chris R.
 
Back
Top