April 2002
Intermediate to advanced
1024 pages
23h 26m
English
Chapter 7, “Leveraging Existing Code—P/Invoke,” dealt with calls into unmanaged code using P/Invoke. Next, you will look specifically at what happens to exceptions that are generated from the unmanaged code.
If an exception is generated in unmanaged code, it is caught and translated to an appropriate managed exception and rethrown. The only exception would be when no appropriate managed exception exists to which to convert. You have already seen that throwing an unspecified exception such as the following
Throw;
results in an SEHException. In fact, any exception that is thrown that cannot be translated to its managed counterpart results in an SEHException.
A sample in the UnmanagedException directory raises four different ...