dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: MSXML usage in VC7 COM IDL file

  1. #1
    Join Date
    Sep 2003
    Posts
    1

    MSXML usage in VC7 COM IDL file

    I used
    #import "c:\winnt\system32\msxml.dll"
    using namespace MSXML2;
    for XML operations. One of the functions in my idl file is as follows.

    [id(1), helpstring("method XmlEle")] HRESULT XmlEle([in] IXMLDOMNode **node);

    The stuff is working fine in VC6 version. When I try to build the same in VC7, The following error is coming.
    error C2872: 'IXMLDOMNode' : ambiguous symbol
    could be 'd:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\MsXml.h(536) : IXMLDOMNode'
    or 'd:\Samples\XMLTest\Debug\msxml3.tlh(2398) : MSXML2::IXMLDOMNode'

    I tried to use the "typelib" namespace MSXML2 to prifix IXMLDOMNode pointer, but it is not working. Can anybody help, how to solve this problem with IDL file?

  2. #2
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    31

    Similar Problem (MSXML in VC7)

    Even I am faced with the similar problem. I am trying to make a ATL COM component in VC7 which will use MSXML4.0 for XML parsing. For that, I have written following lines in one of the classes to generate smartpointers.

    #import "msxml4.dll"
    using namespace MSXML2;

    And, this generates following warning & error:

    warning C4278: 'DOMDocument': identifier in type library 'msxml4.dll' is already a macro; use the 'rename' qualifier

    error C2872: 'ISAXXMLReader' : ambiguous symbol
    could be 'd:\Programs\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\MsXml2.h(12064) : ISAXXMLReader'
    or 'd:\Projects\MyATLComponent\Debug\msxml4.tlh(791) : MSXML2::ISAXXMLReader

    Does anyone has any idea about it ?
    Vivekananad: were you able to resolve your problem ?

    Regards,
    Arun.

  3. #3
    Join Date
    Nov 2003
    Posts
    1
    Same problem for me.

    I tried prefixing with the "typelib" as suggested in MSDN article Q316317 to get MSXML2::IXMLDOMElement, but this gives MIDL error MIDL2025 : syntax error : expecting a type specification near "MSXML2"

    The only way I've managed to get around this so far is to add the following sort of thing at the top and bottom of the IDL file.

    cpp_quote ("#define IXMLDOMElement MSXML2::IXMLDOMElement")

    ... rest of IDL ...

    cpp_quote ("#undef IXMLDOMElement")

    This means that the MIDL file compiles, and the generated header file will have a #define and #undef at the top and bottom that will effectively prefix occurences of IXMLDOMElement with MSXML2:: and remove the aforementioned errors.

    I haven't managed to test this out yet as I'm in the midst of converting tens of other VC6 projects over to VC7 at the same time. I would be greatful if someone can try it out and post a reply.

    If anyone can find a proper solution as opposed to a workaround I would be happier.

  4. #4
    Join Date
    Nov 2003
    Posts
    1
    Hi,

    first take a look at

    http://support.microsoft.com/default...b;en-us;316317

    and

    http://support.microsoft.com/default...b;EN-US;269194

    I solved the problem with this resolution:
    "...The "ambiguous symbol" error can be avoided by using the Msxml.h header file from the Visual C++ 6.0 Include folder. This Msxml.h file contains only the old XML definitions that are necessary to satisfy Comdef.h, but doesn't redefine such newer symbols as DOMDocument. ..."

    Note the attached file. Simply take it to replace the original file wich is located at C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include

    After this you can use your code
    #import "c:\winnt\system32\msxml.dll"
    using namespace MSXML2;


    Regards,
    Erik
    Attached Files Attached Files

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)