How to I get access to a MSXML2.FreeThreadedDOMDocument60 document in
a Microsoft Visual C# 2005 dot net project?
I'm writing a dot net executable that needs to access a by ref XML dom
from a Visual Basic 6 dll. The dll returns XML but I'm not sure how to
type the XML object.
// Dot NET Class
vb6Project.myClass vb6DataObject = new vb6Project.myClass();
MSXML2.IXMLDOMDocument2 _testxml = new MSXML2.IXMLDocument2();
vb6DataObject.GetData(ref _theXml);
// VB 6 Class
Private Function iTheProject_GetData(ByRef theXml As
MSXML2.FreeThreadedDOMDocument60) As Boolean
set theXml = getXMLDoc()
end function
With all the things I've tried, I get one of two errors:
Error 1 Cannot create an instance of the abstract class or interface
'MSXML2.IXMLDOMDocument2'
or
cannot convert from '[ref MSXML2.FreeThreadedDOMDocument]' to 'ref
MSXML2.IXMLDOMDocument2'
Maybe there's a lot more to it then just passing in the correct
object? Any help and/or code examples will be greatly appreciated.
-- i
Anthony Jones - 21 Feb 2008 22:30 GMT
> How to I get access to a MSXML2.FreeThreadedDOMDocument60 document in
> a Microsoft Visual C# 2005 dot net project?
[quoted text clipped - 26 lines]
> Maybe there's a lot more to it then just passing in the correct
> object? Any help and/or code examples will be greatly appreciated.
It looks to me that getXMLDoc in the VB6 app is creating the object so stop
using new MSXML2.IXMLDocument2 in the C#.
Since MSXML2.FreeThreadedDOMDocument and MSXML2.IXMLDOMDocument2 are
different types you can't pass one to the other ByRef.
If you change the GetData signature to:-
GetData(ByRef theXml as MSXML2.IXMLDOMDocument2)
then that may work.
However the Function is declared Private so I'm not sure how your C# manages
to call it anyway. Also why use a ByRef parameter? Can't the function
simply return the DOM instead.

Signature
Anthony Jones - MVP ASP/ASP.NET