Microsoft KB Archive/282068

= BUG: Error MIDL2311 When You Compile an MFC ActiveX Control with Internet Explorer 5.5 Headers =

Article ID: 282068

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q282068



SYMPTOMS
When you compile a Microsoft Foundation Class (MFC) ActiveX control project with the Internet Explorer 5.5 header files, you may receive the following error message:

error MIDL2311 : statements outside library block are illegal in mktyplib compatability mode : [ ]



CAUSE
This problem occurs because the Olectl.h file, as shown below, does not hide the #pragma once directive as expected:
 * 1) ifndef _OLECTL_H_
 * 2) define _OLECTL_H_


 * 1) if _MSC_VER > 1000
 * 2) pragma once
 * 3) endif

Olectl.h is located in the Ie55headers\Ie55_lib\Include folder.
 * 1) if !defined(__MKTYPLIB__) && !defined(__midl)



RESOLUTION
There are two ways to work around this problem:   Modify the top of Olectl.h to hide the #pragma once directive as follows:
 * 1) ifndef _OLECTL_H_
 * 2) define _OLECTL_H_


 * 1) if !defined(__MKTYPLIB__) && !defined(__midl)

 Because you receive the error only when the directory that contains the Internet Explorer 5.5 headers is the first directory for the Internet Explorer headers, you can rearrange the include directory order. To do this, follow these steps:  On the Tools menu, click Options. On the Directories tab, change the include directory order in the Microsoft Visual C++ Integrated Development Environment (IDE) so that another include directory that contains Olectl.h and the Internet Explorer 5 headers precedes the Internet Explorer 5.5 headers.
 * 1) if _MSC_VER > 1000
 * 2) pragma once
 * 3) endif

NOTE: This prevents you from using any of the headers in Internet Explorer 5.5. 

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

MORE INFORMATION
When you program with the new features in Internet Explorer 5.5, you must download the Headers and Libraries and install them onto your development environment. You can download the Headers and Libraries for Internet Explorer 5.5 from the following Microsoft Web site:

http://msdn.microsoft.com/downloads/samples/internet/libraries/ie55_lib/sample.asp

<div class="references_section">