Microsoft KB Archive/251246

= PRB: XML DOMDocuments Created in Separate Processes Cannot Be Combined =

Article ID: 251246

Article Last Modified on 10/13/2001

-

APPLIES TO


 * Microsoft Internet Explorer 5.0
 * Microsoft XML Parser 2.0
 * Microsoft XML Parser 2.5
 * Microsoft XML Parser 2.6
 * Microsoft XML Core Services 4.0
 * Microsoft XML Core Services 4.0

-



This article was previously published under Q251246



SYMPTOMS
If you create an XML document in one process, pass that XMLDOMDocument to another process (say, for example, an Microsoft Transaction Server component), and try to create a new XML DOMDocument using a node or element from the first XML document, you will receive this error message:

Run Time Error -2147024809 (80070057) The parameter is incorrect.



RESOLUTION
Instead of creating the XML DOMDocuments in separate processes, you can create both XML DOMDocuments in one process, and then pass them as parameters into your Microsoft Transaction Server component.

For example, if you are using Microsoft Visual Basic, instead of having: Public Function GetNode(xmlDoc as MSXML.DOMDocument) as MSXML.DOMDocument you could have: Public Sub GetNode(xmlDoc as MSXML.DOMDocument, xmlReturn as MSXML.DOMDocument)



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Create a new Visual Basic Standard EXE project. Add a reference to Microsoft XML, version 2. Add a command button to the form1.  Paste the following code into Command1's click event: Dim xmlDoc As New MSXML.DOMDocument Dim xmlReturnedDoc As MSXML.DOMDocument Dim obj As XMLTest.TestObject Set obj = CreateObject("XMLTEST.TestObject") xmlDoc.Load "C:\my.xml" set xmlReturnedDoc = obj.GetNode(xmlDoc) xmlReturnedDoc.save "C:\output.xml"

Set obj = Nothing Set xmlDoc = Nothing Set xmlReturnedDoc = Nothing  Note that you must change the xmlDoc.Load and xmlReturnedDoc.save paths to point to an appropriate location for the XML test files on your drive.  Create the file C:\My.xml, and then paste the following XML into it: AWG A0-FX Aruba Guilder 1.79    CRC A0-FX Costa Rica Colones 228.93    HTG A0-FX Haiti Gourde 16.26    PAB A0-FX Panama Balboa 1                    </li> Add a new Microsoft ActiveX DLL project to your Visual Basic session, creating a project group. Name the project XMLTest, and name the class module that is created by default as TestObject .</li>  Paste the following code into TestObject: Public Function GetNode(x As MSXML.DOMDocument) as MSXML.DomDocument

Dim xmlDoc As MSXML.DOMDocument Dim xmlNode As MSXML.IXMLDOMNode Dim pi As MSXML.IXMLDOMProcessingInstruction Set xmlDoc = New MSXML.DOMDocument Set pi = xmlDoc.createProcessingInstruction("xml", " version=""1.0""") xmlDoc.insertBefore pi, xmlDoc.childNodes.Item(0)

'Clone the benefit node from the request XML. Set xmlNode = x.selectSingleNode("//currency").cloneNode(True) xmlDoc.appendChild xmlNode 'Return the XML. Set GetNode = xmlDoc

'Clean up objects. Set xmlDoc = Nothing Set xmlNode = Nothing Set pi = Nothing End Function </li> Compile the .dll and the .exe files.</li> Add a reference to the XMLTestProject.exe for XMLTest.</li> Run XMLTestProject.exe. Because the .dll file is pulled into the .exe's space, the XMLDocuments are created in the same process: You should not get any errors.</li> Import the .dll file into Microsoft Transaction Server.</li> Run XMLTestProject.exe. It should fail with the error "Run Time Error -2147024809 (80070057) The parameter is incorrect."</li></ol>

If a newer version of MSXML has been installed in side-by-side mode, you must explicitly use the Globally Unique Identifiers (GUIDs) or ProgIDs for that version to run the sample code. For example, MSXML version 4.0 can only be installed in side-by-side mode. For additional information about the code changes that are required to run the sample code with the MSXML 4.0 parser, click the following article number to view the article in the Microsoft Knowledge Base:

305019 INFO: MSXML 4.0 Specific GUIDs and ProgIds

Keywords: kbprb KB251246

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.