[Last Call] Learn how to a build a cloud-first strategyRegister Now


Imported typelib from 6.0 not working in .NET

Posted on 2004-11-23
Medium Priority
Last Modified: 2013-11-25

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.


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.

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?
Question by:Crius
1 Comment
LVL 48

Accepted Solution

AlexFM earned 1000 total points
ID: 12662617
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.

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Suggested Courses

834 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