This article was previously published under Q316317
When you use MSXML parser dynamic-link libraries (DLLs) such as Msxml.dll, Msxml2.dll, Msxml3.dll, or Msxml4.dll to compile a Visual C++ .NET project with #import, you may receive the following compiler error messages:
c:\sample\test.cpp(12) : error C2872: 'IXMLDOMDocumentPtr' : ambiguous symbol
could be 'c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\comdefsp.h(1228) : _com_ptr_t<_IIID> IXMLDOMDocumentPtr' with [ _IIID=_com_IIID<IXMLDOMDocument,& _GUID_2933bf81_7b36_11d2_b20e_00c04f983e60> ]
or 'c:\sample\Debug\msxml3.tlh(226) : MSXML2::IXMLDOMDocumentPtr'
c:\sample\test.cpp(16) : error C2039: 'async' : is not a member of 'IXMLDOMDocument' c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\MsXml.h(1845) : see declaration of 'IXMLDOMDocument'
c:\sample\test.cpp(27) : error C2660: 'IXMLDOMDocument::load' : function does not take 1 parameters
You may also see other C2039 and C2660 errors in the output. The workaround that is described in the following Knowledge Base article does not resolve the compiler errors with Microsoft Visual C++ .NET:
269194 PRB: Compiler Errors When You Use #import with XML
The "ambiguous symbol" error occurs when a smart pointer interface definition such as IXMLDOMDocumentPtr is defined in both the MSXML2 namespace (through #import) and the global namespace (through Msxml.h), so that the symbol is ambiguous. When the compiler resolves the interfaces, the compiler looks first in Msxml.h, which has different signatures than those that #import generates.
To resolve this problem, use the "typelib" namespace with MSXML parser DLLs to prefix the interface pointers and globally unique identifiers (GUIDs). To avoid the errors, explicitly qualify the interface declaration and GUIDs to remove the ambiguity, as follows:
The #import feature includes a file named Comdef.h that indirectly includes Urlmon.h, which in turn includes Msxml.h. This is necessary because the end of Comdef.h includes Comdefsp.h, which defines many common GUIDs and XML interfaces. For example, the following sample causes Msxml.h to be included before the .tlh file: