Exceptions in native dll's?

O

ORC

How to catch exceptions that happens in a native DLL? I have an application
that calls a function in a native dll but even though the dll call is in a
try statement it doesn't get catched - the exception is thrown outside my
application and my application is closed by the system????. A specific
example is if the native dll tries to open a file that isn't there. - Any
suggestion?

Thanks,
Ole
 
A

Alex Feinman [MVP]

If this is your own DLL - add exception handling there. Otherwise either
write your managed code so that it does not throw unmanaged exceptions, or
wrap unmanaged DLL into another unmanaged DLL that has exception handling.
Managed exceptin handlers cannot catch unmanaged execptions
 
O

ORC

OK- thanks Alex.

Ole

Alex Feinman said:
If this is your own DLL - add exception handling there. Otherwise either
write your managed code so that it does not throw unmanaged exceptions, or
wrap unmanaged DLL into another unmanaged DLL that has exception handling.
Managed exceptin handlers cannot catch unmanaged execptions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top