Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

Access violation when calling $IXMLDOMNode_appendChild from msxml6.dll via COM interface

thomas_boehme
New Contributor II
582 Views

I am experiencing unexpected access violations when using Microsoft'smsxml6.dll via a COM interface. I attached a simple VS2008 project to illustratethe problem.

Initially, I made an interface file for msxml6.dll via the Intel Fortran Module Wizard. In order to get this interface file to compile cleanly, Ifirst removed the parameterdefinitions for XML node types, as these parameters seem to be already defined in either the module IFCOM or IFWINTY. Also I had to replace all occurances of INTEGER(2), INTENT(OUT) by INTEGER(4), INTENT(OUT).

After these modifications, the interface definition compiles ok and I can call most msxml6.dll functions without problems. I can read xml files, get content from them, create nodes, etc.

However, I cannot get $IXMLDOMNode_appendChild(XMLDocument, XMLNode, XMLNodeOut) (line 24 in MSXML_FORTRAN.f90) to work. Everytime I try to add a node to a existing DOM structure, it results in an access violation and I could not find areason for it.

Alternatively, I tried to passthe pointers XMLDocument and XMLNode to a C++ subroutine (with extern "C" interface) and call IXMLDOMNode::appendChild() from the C++ subroutine. To my supriseeverythings works well. Therefore, the object I want to add and the reference to the parent node seem to be fine. The problem seems to be in the call to appendChild in FORTRAN. Is it possible that the interface definitioncreated by theModule Wizard is incorrect?

I would be very happy for any assistance regarding this problem. The workaround using a C++ function is less than elegant. It requires me touse a mixed languagesolution even thoughI do not really need any C++ in the project.

Best regards,
Thomas Boehme

0 Kudos
1 Reply
thomas_boehme
New Contributor II
582 Views
I finally have found the reason for the access violation I have been getting.

It seemsthat the interface definitiongenerated by the Intel VFortran Module Wizard for the function $IXMLDOMNode_appendChild($OBJECT, newChild, OutNewChild)isincorrect.

Per default, the parameters are listed as

INTEGER(INT_PTR_KIND()), INTENT(IN) :: $OBJECT ! Object Pointer
!DEC$ ATTRIBUTES VALUE :: $OBJECT
INTEGER(INT_PTR_KIND()), INTENT(IN) :: newChild ! IDispatch
!DEC$ ATTRIBUTESREFERENCE :: newChild
INTEGER(INT_PTR_KIND()), INTENT(OUT) :: outNewChild ! IDispatch
!DEC$ ATTRIBUTES REFERENCE :: outNewChild

However, it seems like newChild should be passed by value and not by reference. If I change the attributes for newChild to

!DEC$ ATTRIBUTESVALUE :: newChild

in both $IXMLDOMNode_appendChild() and IXMLDOMNode_appendChild() the functions works correctly without giving an access violaiton.

Now, theremaining question is, whether this incorrect function interface is caused by the Intel Visual Fortran Module Wizard or whether the interface description within the msxml6.dll is wrong. Does anybody have a clue how to find out? Is there any tool available that I can use to see the interface definitons contained in a COM dll?

Any help would be greatly appreciated,
Thomas Boehme


0 Kudos
Reply