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



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 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:
#ifndef _OLECTL_H_
#define _OLECTL_H_

#if _MSC_VER > 1000
#pragma once
#endif

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

RESOLUTION

There are two ways to work around this problem:
  • Modify the top of Olectl.h to hide the #pragma once directive as follows:
    #ifndef _OLECTL_H_
    #define _OLECTL_H_
    
    #if !defined(__MKTYPLIB__) && !defined(__midl)
    
    #if _MSC_VER > 1000
    #pragma once
    #endif
    					
  • 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:
    1. On the Tools menu, click Options.
    2. 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.

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

STATUS

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

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:

REFERENCES

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

Modification Type:MajorLast Reviewed:5/11/2006
Keywords:kbBug kbCtrl kbpending KB282068