Imported typelib from 6.0 not working in .NET

Description:

In Visual Studio 6.0, we imported the msxml3.dll typelib, and it created msxml3.h and msxml3.cpp which we added to our project.

Here is an example of one of the functions in the msxml3.dll:

// Machine generated IDispatch wrapper class(es) created with ClassWizard

/////////////////////////////////////////////////////////////////////////////
// IXMLDOMNode operations

CString IXMLDOMNode::GetNodeName()
{
      CString result;
      InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
      return result;
}

As can clearly be seen, it returns an MFC style CString, and is a wrapper class.

Problem:

We have been asked to move this project to Visual Studio .NET, and it doesn't seem able to work with this class properly. Here are some of the errors:

c:\mam\src\v25_71\mamsignoff\msxml3.h(5) : error C2011: 'IXMLDOMNode' : 'struct' type redefinition

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\MsXml.h(537) : see declaration of 'IXMLDOMNode'
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\MsXml.h(1846) : see declaration of 'IXMLDOMDocument'

msxml3.cpp(20) : error C2039: 'GetNodeName' : is not a member of 'IXMLDOMNode'
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\MsXml.h(537) : see declaration of 'IXMLDOMNode'

msxml3.cpp(23) : error C3861: 'InvokeHelper': identifier not found, even with argument-dependent lookup

It looks like there is a conflict between msxml.h and our machine generated msxml3.h. It will not recognize our file, even though we do not explicitly include msxml.h anywhere.

Solutions considered and discarded:
We don't want to rewrite all of our code to construct BSTRs and use COM to work with the msxml3.dll raw interfaces. It's too big of a rewrite at this time.
We don't want to exclude the standard include libraries path since our project source consists of about 4700 files at this time.

Question:
Is there an easy way to convert, create, or get to work the msxml3.cpp idispatch interface that Visual Studio 6.0 created within the Visual Studio .NET environment?
LVL 3
CriusAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexFMCommented:
To prevent name collisions you can use namespaces. #import directive may be used with rename_namespace attribute. If you are using no_namespace attribute, remove it. Client code should use namespace prefix working with types generated by #import.
If there are few name collisions, it is possible to use the rename attribute.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.