|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to catch win32 dll exception in c#?"BEelzebub" <beelzebub2***@163.com> wrote in message If a C++ exceptions is thrown, you can catch the exception as a news:23I4bbrrjGHA.4512@TK2MSFTNGP02.phx.gbl... > how to catch win32 dll exception in c#? System::Runtime::InteropServices::SEHException. If a Win32 SEH exception is thrown, it depends on the exception code. Most exception codes are also caught as System::Runtime::InteropServices::SEHException, but there are some exceptions. E. g. The exception code EXCEPTION_INT_DIVIDE_BY_ZERO is mapped to a System::DevideByZeroException. If you use this exception mapping intensively, you should also notice that there is a breaking change in v2.0: EXCEPTION_ACCESS_VIOLATION is caught as System::AccessViolation in 2.0, whereas it is caught as System::NullReferenceException in 1.1 and 1.0. To get the old behavior you can add an element <legacyNullReferenceExceptionPolicy enabled="1"/> to the <runtime> element of your config file. However, in all these cases, you loose significant aspects of your exception. If you can not afford this, you have to use C++/CLI, where you can catch Win32 exceptoins as well as C++ exceptions in managed code. Marcus Heege DevelopMentor |
|||||||||||||||||||||||