FIX: Error in COleDispatchException Constructor (140590)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 4.0
- Microsoft Visual Basic Professional Edition for Windows 4.0
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++ for Windows, 16-bit edition 1.51
- Microsoft Visual C++ for Windows, 16-bit edition 1.52
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 2.1
- Microsoft Visual C++, 32-bit Editions 2.2
- Microsoft Visual C++, 32-bit Editions 4.0
This article was previously published under Q140590 SYMPTOMS
In an MFC application, AfxThrowOleDispatchException is used to throw an
exception from within an OLE Automation function. When Microsoft Visual
Basic is used as the automation client application, it will not be able to
correctly interpret the error code passed to AfxThrowOleDispatchException.
CAUSE
AfxThrowOleDispatchException constructs and throws a COleDispatchException
object, which is used to handle exceptions specific to the OLE IDispatch
interface. The constructor of COleDispatchException incorrectly initializes
the COleDispatchException object, resulting in the Visual Basic client
being unable to interpret the error code of the exception.
RESOLUTION
To implement the proper behavior for throwing an OLE dispatch exception
from an MFC server, do not use AfxThrowOleDispatchException. Instead,
construct your own COleDispatchException, set m_scError = 0, and throw the
exception yourself as illustrated in the sample code in this article.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products
listed at the beginning of this article. This bug was corrected in
Visual C++ 4.1.
REFERENCES
"Inside OLE" second edition by Kraig Brockschmidt, published by Microsoft
Press, Chapter 14, pages 658 - 660.
Modification Type: | Major | Last Reviewed: | 12/9/2003 |
---|
Keywords: | kbAutomation kbBug kbfix kbNoUpdate kbVC410fix KB140590 |
---|
|