PRB: Error Message When MSXML DOMDocument Is Loaded by Supplying an ADO 2.5 Stream Object (283164)



The information in this article applies to:

  • Microsoft XML 2.0
  • Microsoft XML 2.5
  • Microsoft XML 2.6
  • Microsoft XML 3.0
  • Microsoft XML 3.0 SP1
  • Microsoft XML 4.0
  • ActiveX Data Objects (ADO) 2.5
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q283164

SYMPTOMS

If you attempt to run the Load method of an MSXML DOMDocument object by supplying an ActiveX Data Object (ADO) 2.5 Stream object that contains valid XML data as the xmlSource parameter, the following error message is generated:
Run-time error '5': Invalid procedure call or argument

CAUSE

A string that specifies the path of the XML file to be loaded, or a Component Object Model (COM) object that is queryable for the IStream interface can be supplied as the xmlSource parameter when you run the Load method of the DOMDocument object. The ADO 2.5 Stream object is not internally queryable for the IStream interface.

RESOLUTION

There are two possible solutions to the problem:
  • If you upgrade to MDAC 2.6, the problem does not occur when you supply an ADO 2.6 Stream object as the xmlSource parameter for the Load method of an MSXML DOMDocument object. The ADO 2.6 Stream object is internally queryable for the IStream interface. -or-

  • If you cannot upgrade to MDAC 2.6, the ReadText method of the ADO 2.5 Stream object returns the contents of an adTypeText Stream object as a string. Run the loadXML method of the MSXML DOMDocument and supply the string returned by running the ReadText method of the Stream object as the bstrXML parameter.

STATUS

This problem has been fixed in MDAC 2.6. The Implementation of the ADO 2.6 Stream object has been modified to make it internally queryable for the IStream interface.

For more information, see the MDAC pages on the following Microsoft Web site at:

MORE INFORMATION

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

Steps to Reproduce Behavior

NOTE: This Visual Basic sample references version 3.0 of the MSXML parser. You can reference a prior version of the MSXML parser in your Visual Basic project if you have not installed version 3.0.

The installation of MDAC 2.6 replaces the core ADO DLL (msado15.dll) that implements the ADO Stream object. Therefore, the problem cannot be reproduced by referencing the ActiveX Data Objects 2.5 type library (msado25.tlb) after you install MDAC 2.6.

Follow the steps that are listed here to reproduce the problem that is specified in the "Symptoms" section of this article:
  1. Open a new Standard EXE project in Visual Basic. Form1 is created by default.
  2. On the Project menu, choose References, and then set references to Microsoft ActiveX Data Objects 2.5 Library and Microsoft XML, v3.0.
  3. Add a CommandButton to Form1.
  4. Copy and paste the following code in the Click event procedure of the CommandButton:
    Dim xmldoc As MSXML2.DOMDocument30
    Dim strm As ADODB.Stream
    
    Set strm = New ADODB.Stream
    strm.Type = adTypeText
    strm.Charset = "ascii"
    strm.Open
    strm.WriteText "<Book>XML Programming</Book>"
    strm.Position = 0
    
    'Change the ProgID of the DOMDocument object in the following statement
    'as required if you are referencing an older version of the MSXML parser.
    Set xmldoc = New MSXML2.DOMDocument30
    
    xmldoc.Load strm
    Debug.Print xmldoc.xml
    					
  5. Save and run the project.
  6. Click the CommandButton when the form is displayed, and note that the xmldoc.Load statement generates the error specified in the "Symptoms" section of this article.
  7. Stop the project by clicking End.
  8. Replace the xmldoc.Load statement with the following line of code, and then save the project:
    xmldoc.loadXML strm.ReadText
    					
  9. When you run the project and click the CommandButton on the form that is displayed, note that the error does not occur. The XML data that is loaded into the DOMDocument object by supplying the ADO stream object as the xmlSource parameter is written out to the Visual Basic Debug window.

Modification Type:MajorLast Reviewed:3/7/2003
Keywords:kbprb KB283164 kbAudDeveloper