views:

516

answers:

4

I am changing my C++ project, which was earlier in VC6 and now being migrated to VS 2008, to use MSXML 6 instead of the earlier MSXML 3. When the code was in VC6 we were using MSXML3 by importing it

# import "msxml3.dll"

This was replaced with

# import "msxml6.dll"

After this when I compile the project I get this and several other similar errors Error C2011: 'MSXML2::IXMLDOMImplementation' : 'struct' type redefinition

The above error is in the msxml3.tlh file.

1) Why is msxml3 still being used?

2) I narrowed down the problem to MSXML.h which is somehow automatically being included in my project. Why is this?

3) Which version of MSXML is being referenced in MSXML.h?

4) Why in the world does VC++ automatically include so many header files? What if I dont want some header files to be included?

5) What is the right way of using MSXML6 in a c++ project? #import, header file?????

6) How do I fix this problem?

Give me .net any time. Much cleaner. A VC++ project is a mess.

A: 

Have a look at the MS docoumentation on MSXML. They suggest that importing the .dll as you have will create a couple of .thl and .tli files. Make sure you've deleted those.

Make sure any include directories point to the right place.

Make absolutely certain that you're not importing msxml3 somewhere else in your project.

To find the msxml.h do CTRL + SHIFT + F and search you entire solution for 'msxml' <- note the lack of the .h because if you'd been importing it properly, it ought to be done as follows:

#include <msxml6.dll>

Try some of that...

Jon Cage
can you # include a dll?
Bobby Alexander
I have cleaned the project. The tlh and tli files gets recreated automatically. I have searched the entire solution for msxml3 and there is nothing left. Its all msxml6.
Bobby Alexander
A: 

Perhaps this might help you in your quest.

Cheers !

Magnus Skog
Magnus, Thanks for the link but I have already come across this while I was googling for an answer. The suggestions doesn't seem to help. Or may be I am reading it all wrong.
Bobby Alexander
A: 

I'd try renaming msxml.h and doing a build. That should show you what file is including msxml.h.

Michael Dunn
+1  A: 

Check the syntax of the #import directive. You can rename imported elements using rename attribute on import directive (or rename_namespace). It will resolve conflicts with duplicated elements.

See here: in MSDN

Sometimes change of the inclusion order (yes - try different order of the include and import statements by commenting them out)

Don't fight with the MS mistakes, just cross them ;)

Alex Stankiewicz