FIX: Platform SDK Prevents MFC Projects from Compiling (243503)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q243503 SYMPTOMS
When compiling a MFC ActiveX project with Microsoft Visual C++ 6.0 and the Platform SDK installed, you may get compiler errors when building the project. You may get a "C2146" error in the project C++ source file for the CWinApp derived class not being defined.
This did not happen before installing the Platform SDK.
CAUSE
This is due to the project header file being overwritten by the MIDL compiler generated header file. This only happens when the /mktyplib203 switch is not specified when compiling an .odl file and the .odl file has the following line of code outside of the library block.
#include <olectl.h>
RESOLUTION
At this time, it is recommended to not select the MkTypLib compatible option when building MFC ActiveX components. This option can be found from Project menu Settings menu and then select MIDL tab.
Removing the MkTypLib compatible option may overwrite the project header file that results in the compiler error mentioned in the "Symptoms" section of this article. Instead, move any #include statements in the .odl file inside of the library block. For example:
[ uuid(9D830476-7DAB-11D3-9D15-00C04F542A77), version(1.0),
helpfile("testodl5.hlp"),
helpstring("testodl5 ActiveX Control module"),
control ]
library TESTODL5Lib
{
#include <olectl.h> //move this to here to prevent any MIDL 2311 errors
#include <idispids.h>
importlib(STDOLE_TLB);
importlib(STDTYPE_TLB);
//...rest of code omitted
}
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This problem was corrected in the Microsoft Platform SDK January 2000 Edition.
REFERENCESFor additional information%1, click the article number%2 below
to view the article%2 in the Microsoft Knowledge Base:
243219 FIX: Platform SDK Causes MIDL to Throw MIDL2311 Error
Modification Type: | Major | Last Reviewed: | 12/8/2003 |
---|
Keywords: | kbBug kbfix kbfix kbIDL kbMIDL KB243503 |
---|
|