locked
not able to pass DOM object from mfc application to .net dll RRS feed

  • Question

  • Hello,

    I have created a C#.Net dll and expose it for COM interop so that I can use methods of this class from legacy MFC 6.0 or VB6 applications using COM technology.

    In this .net dll, i have expose a method and this method expect a DOM object as a parameter.

    void TestFunctionForDom(XmlDocument mydom);

    then I created a mfc application(in VC++6) which actually uses this .net dll. My mfc application is client of this dll.

    In this mfc application, I have created a DOM object.

    IXMLDOMDocument *pXMLDom=NULL;
    pXMLDom->load(some xml file); 

    (my mfc application loading xml into DOM correctly, I have done all tests, dom object is created correctly.)

    now, when i pass this DOM object using method expoese by .net dll,
    .net dll is not able to read dom object.

    please help me , how to pass dom object between MFC and .net using COM technology.

    does COM support XmlDocument data type?

    Do I need to use System.Object datatype instead of XmlDocunet and then typecast it to XmlDocument?

    Many thanks ,


    dipak mistry
    Monday, June 23, 2008 2:00 PM

Answers

  • XmlDocument is a .NET class, a very different animal from the IXmlDOMDocument COM interface.  Afaik, the .NET framework doesn't offer any methods to turn an IXmlDocument interface pointer into an XmlDocument class instance.  You could add a reference to c:\windows\system32\msxml3.dll to get a definition of the IXmlDOMDocument interface.  Or let the COM client pass you the name of the document so you can load it yourself.
    Hans Passant.
    • Marked as answer by Bruno Yu Thursday, June 26, 2008 3:20 AM
    Monday, June 23, 2008 6:31 PM

All replies

  • XmlDocument is a .NET class, a very different animal from the IXmlDOMDocument COM interface.  Afaik, the .NET framework doesn't offer any methods to turn an IXmlDocument interface pointer into an XmlDocument class instance.  You could add a reference to c:\windows\system32\msxml3.dll to get a definition of the IXmlDOMDocument interface.  Or let the COM client pass you the name of the document so you can load it yourself.
    Hans Passant.
    • Marked as answer by Bruno Yu Thursday, June 26, 2008 3:20 AM
    Monday, June 23, 2008 6:31 PM
  • Thanks  a lot!!!!
    dipak mistry
    Tuesday, June 24, 2008 2:37 PM