You may receive the "ATLASSERT" error message while hosting an ActiveX control in a COM DLL that is statically linked to the ATL in Visual C++ .NET or in Visual C++ 2005 (832687)



The information in this article applies to:

  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)

SYMPTOMS

When you try to create and to display the Microsoft Internet Explorer control or the Microsoft Foundation Classes (MFC) ActiveX Controls that request ambient properties and that link statically to the Active Template Library (ATL) in an COM DLL application, you may receive the following error message:

ATLASSERT(!InlineIsEqualGUID(*m_plibid, GUID_NULL) && "Did you forget to pass the LIBID to CComModule::Init?");

from line 3552 in ATLCOM.H

MORE INFORMATION

You may receive the error message that is mentioned in the "Summary" section only if you link statically to the ATL library in a COM DLL application with MFC support. If you dynamically link to the ATL library or if your application is of the EXE type instead of the DLL type, you may not receive this error message. However, you may experience other problems, such as a heap corruption or a memory leak.

Additionally, you may receive the error message when you try to create controls, such as the Internet Explorer control, the MFC ActiveX Controls, and controls that request ambient properties. You may not receive the error message when you create controls, such as the Calendar control and the Grid control.

This problem occurs because the IAxWinAmbientDispatchEx interface is not included if you statically link to the ATL. The IAxWinAmbientDispatchEx interface implements supplemental ambient properties for a hosted control.

The documentation for the IAxWinAmbientDispatchEx interface that is mentioned in the "References" section notes that you must add the following code after the other import statements in your .idl file:
import "atliface.idl" 
You also must add the following code in the library block:
interface IAxWinAmbientDispatchEx;
However, you may still receive the following error message:

LIBID is not getting set
This error message occurs because of the way that the class override is handled in the ATL. This is a bug. To work around this problem, verify that you declared the LIBID of your library in your project as shown in the following code sample:
DECLARE_LIBID(LIBID_MyProjectLib)
Also, verify that you set the LIBID in your project by using either of the following code sample statements:
_Module.Init(ObjectMap, hInstance, &LIBID_MyProjectLib);
_AtlModule.m_libid = LIBID_MyProjectLib;
Note In the previous code sample, MyProjectLib is a placeholder for the name of your library.

REFERENCES

For additional information about the IAxWinAmbientDispatchEx interface, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MinorLast Reviewed:1/12/2006
Keywords:kbprb kbDLL kbCtrlCreate kbCOMServices kbATLServer kbActivexEvents kbDebug kberrmsg KB832687 kbAudDeveloper