Error importing msxml3.dll
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Error importing msxml3.dll

  1. #1
    Join Date
    Jun 1999
    Location
    Leiden, the Netherlands
    Posts
    116

    Error importing msxml3.dll

    In my file I import msxml3 like this:

    #import "msxml3.dll"
    using MSXML2::IXMLDOMDocument2Ptr;
    using MSXML2::IXMLDOMNodePtr;

    And i get the following error:

    error C2874: using-declaration causes a multiple declaration of 'MSXML2::IXMLDOMNodePtr'
    c:\Source\3.0\modes\Q3DPublisher\Debug\msxml3.tlh(287) : see declaration of 'MSXML2::IXMLDOMNodePtr'

    Note that eliminating the "using MSXML2::IXMLDOMNodePtr" statement makes the pointer only be usable by typing the namespace (which I do not want)

    "using namespace MSXML2" gives an error (which is confirmed in MSDN), so I cannot use that one.

    Does anyone have a suggestion on how to use MSXML3 without problems?

  2. #2
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    7,994

    Re: Error importing msxml3.dll

    Quote Originally Posted by Arthur
    "using namespace MSXML2" gives an error (which is confirmed in MSDN), so I cannot use that one.
    What says that error "which is confirmed in MSDN"?
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  3. #3
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Error importing msxml3.dll

    Quote Originally Posted by Arthur
    Note that eliminating the "using MSXML2::IXMLDOMNodePtr" statement makes the pointer only be usable by typing the namespace (which I do not want)
    Why don't you want this?
    It is not only more readable, but it also solves your problem.

    However, if you still find using namespaces with every object-type a nuisance, a solution would be to typedefine your own type.
    Like this -
    Code:
    typedef MSXML2::IXMLDOMNodePtr DOMPTR;
    ...And use it -
    Code:
    DOMPTR pDOM;

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Error importing msxml3.dll

    However, if you still find using namespaces with every object-type a nuisance, a solution would be to typedefine your own type.
    Like this -
    Or importing the entire namespace:
    Code:
    #import <msxml3.dll>
    using MSXML2;
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  5. #5
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Error importing msxml3.dll

    I think Cilu means this -
    Code:
    using namespace MSXML2;
    ...Which doesn't seem to help this particular case (refer OP).
    Last edited by Siddhartha; March 9th, 2006 at 12:12 PM.

  6. #6
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Error importing msxml3.dll

    I think Cilu means this -
    Doh...

    Quote Originally Posted by Arthur
    "using namespace MSXML2" gives an error (which is confirmed in MSDN), so I cannot use that one.
    And what error is that? I can use it without problems.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  7. #7
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Error importing msxml3.dll

    OK. I got it: PSS ID Number: 316317

    CAUSE
    The "ambiguous symbol" error occurs when a smart pointer interface definition such as IXMLDOMDocumentPtr is defined in both the MSXML2 namespace (through #import) and the global namespace (through Msxml.h), so that the symbol is ambiguous. When the compiler resolves the interfaces, the compiler looks first in Msxml.h, which has different signatures than those that #import generates.

    RESOLUTION
    To resolve this problem, use the "typelib" namespace with MSXML parser DLLs to prefix the interface pointers and globally unique identifiers (GUIDs).

    STATUS
    This behavior is by design.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  8. #8
    Join Date
    Jun 1999
    Location
    Leiden, the Netherlands
    Posts
    116

    Re: Error importing msxml3.dll

    Correct, that was the MSDN topic, thanx!

    I guess I'll just have to prefix it with MSXML2::

    To Siddharta:
    It is not only more readable, but it also solves your problem.

    With the second I agree, with the first I don't. I regularly use small namespaced classes in which I prefer not to refer to other namespaces again and again, but rather use the 'using' statement. Just to keep small lines of code, easy to read.

    But that's only a matter of taste and what kind of coding standard you use in your project of course.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center