Imported typelib from 6.0 not working in .NET

Posted on 2004-11-23
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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    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…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    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.…

    779 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

    19 Experts available now in Live!

    Get 1:1 Help Now