FIX: __declspec(dllimport) Classes Are Not Caught Correctly (122303)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 2.0
This article was previously published under Q122303 SYMPTOMS
C++ Exception Handling (EH) can be used to throw and catch objects of a
specified type. If a class declared with the __declspec(dllimport) keyword
is thrown, it will not be recognized by the catch handler for that type.
If a handler for unspecified types, catch (...), is present, the
__declspec(dllimport) object will be caught in that handler. Otherwise, it
will not be handled, and an exception will terminate the application or
cause a general protection (GP) fault.
RESOLUTION
To work around this problem, derive a class from the __declspec(dllimport)
class, and throw or catch an object of the derived class.
If you are throwing the derived object in one .DLL or .EXE, and catching it
in another, you must do the same derivation in each module.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This problem was fixed in Microsoft
Visual C++, 32-bit Edition, version 4.0.
Modification Type: | Major | Last Reviewed: | 11/13/2001 |
---|
Keywords: | kbbug kbCompiler kbCPPonly KB122303 |
---|
|