Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 283164 - Last Review: March 7, 2003 - Revision: 2.2
PRB: Error Message When MSXML DOMDocument Is Loaded by Supplying an ADO 2.5 Stream Object
This article was previously published under Q283164
On This Page
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Â
(http://kbalertz.com/Feedback.aspx?kbNumber=305019/EN-US/
)
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:
- Open a new Standard EXE project in Visual Basic. Form1 is created by default.
- On the Project menu, choose References, and then set references to Microsoft ActiveX Data Objects 2.5 Library and Microsoft XML, v3.0.
- Add a CommandButton to Form1.
- 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
- Save and run the project.
- 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.
- Stop the project by clicking End.
- Replace the xmldoc.Load statement with the following line of code, and then save the project:
xmldoc.loadXML strm.ReadText
- 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.
APPLIES TO
- Microsoft XML Parser 2.0
- Microsoft XML Parser 2.5
- Microsoft XML Parser 2.6
- Microsoft XML Parser 3.0
- Microsoft XML Parser 3.0 Service Pack 1
- Microsoft XML Core Services 4.0
- Microsoft ActiveX Data Objects 2.5
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please