Microsoft KB Archive/251246
Article ID: 251246
Article Last Modified on 10/13/2001
- 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
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:
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)
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:
<currencies> <currency> <symbol>AWG A0-FX</symbol> <country>Aruba Guilder</country> <rate>1.79</rate> </currency> <currency> <symbol>CRC A0-FX</symbol> <country>Costa Rica Colones</country> <rate>228.93</rate> </currency> <currency> <symbol>HTG A0-FX</symbol> <country>Haiti Gourde</country> <rate>16.26</rate> </currency> <currency> <symbol>PAB A0-FX</symbol> <country>Panama Balboa</country> <rate>1</rate> </currency> </currencies>
- 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.
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
- Compile the .dll and the .exe files.
- Add a reference to the XMLTestProject.exe for XMLTest.
- 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.
- Import the .dll file into Microsoft Transaction Server.
- Run XMLTestProject.exe. It should fail with the error "Run Time Error -2147024809 (80070057) The parameter is incorrect."
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