Solved

Compiling error with MSXML.DLL in VC++ .NET

Posted on 2004-08-29
2
3,282 Views
Last Modified: 2009-01-14
Hi All,

I'm trying to compile a code I write in VC++ 6 to VC++ .NET.

Some parts of the code are using the MSXML to read/write xml files.
When I compile the code I get this erros on the xml DOM objects:

error C2872: 'IXMLDOMNodePtr' : ambiguous symbol

On the StdAfx.h I have this declaration:

//#import "msxml.dll" named_guids raw_interfaces_only
#import <msxml.dll> named_guids
using namespace MSXML;

Please help,
Thanks,
Doron Tal
0
Comment
Question by:doront99
2 Comments
 
LVL 19

Accepted Solution

by:
drichards earned 125 total points
ID: 11928101
If you look closely at the output of the compiler, you see:

d:\DevProjects\CPPConsole\CPPConsole.cpp(77) : error C2872: 'IXMLDOMNodePtr' : ambiguous symbol
        could be 'd:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\comdefsp.h(1249) : _com_ptr_t<_IIID> IXMLDOMNodePtr'
        with
        [
            _IIID=_com_IIID<IXMLDOMNode,& _GUID_2933bf80_7b36_11d2_b20e_00c04f983e60>
        ]
        or       'd:\DevProjects\CPPConsole\Debug\msxml.tlh(105) : MSXML::IXMLDOMNodePtr'


VC7 has a new file 'comdefsp.h' that predefines smart pointers for a lot of interfaces, including the MSXML ones.  comdefsp.h is included by 'comdef.h' which is included by 'msxml.tlh'.  Thus you have two definitions of all the XML interface smart pointers.  If you try to '#import <msxml.dll> no_namespace' you really have problems.  To solve the problem, you can either

1) drop the 'using namespace MSXML;' or

2) explicitly specify either 'MSXML::' or '::' in front of all the ambiguous symbols.

Dropping 'using namespace MSXML;' (option 1) will mean that you need to put 'MSXML::' in front of all the XML stuff, not just the smart pointers.  Take your pick.
0
 

Author Comment

by:doront99
ID: 11928937
Thank you. Now it's working.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now