Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: Cannot Use XML Interfaces Remotely


View products that this article applies to.

This article was previously published under Q259004

↑ Back to the top


Symptoms

When you try to pass an XML interface between execution contexts, such as from a Microsoft Transaction Server component back to its caller or over the network through the use of DCOM, you receive the following error message when you call one of the interface's methods:
HRESULT = 0x800703E6: Invalid access to memory location.

↑ Back to the top


Cause

Pointers to XML interfaces cannot cross execution contexts.

↑ Back to the top


Resolution

If you want to use XML across execution contexts, define a method on your wrappers that passes the raw XML data back to the caller (which you obtain through the use of IXMLDOMDocument::get_XML()). The caller can then call IXMLDOMDocument::loadXML(BSTR) on this string to restore the XML object locally.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


More information

Many developers want to create wrappers for MSXML and return pointers to interfaces such as IXMLDOMDocument directly from these wrappers. This works fine except when the interface must cross execution contexts. Execution contexts are crossed whenever the wrapper and its caller exist in two different types of COM apartments, in two different processes (such as when the component is used under Microsoft Transaction Server), or on two different computers.

In order for an interface to cross execution contexts in COM, the interface must be marshalable. COM must be able to serialize the pointer to the interface into a stream of bits that can be transferred to the other execution context.

Few people write marshaling code by hand. You can use Microsoft Interface Definition Language (MIDL) with the Microsoft IDL compiler to create marshaling code. MIDL creates the code for required proxy and stub marshaling objects when it compiles the IDL for a COM interface. IDL syntax allows interface declarations to define the attribute local, which prevents MIDL from compiling this marshaling code. This attribute is defined on all of the MSXML interfaces, as you can see by examining the MSXML.idl file that is included with Visual C++:
[
    local, object,
    uuid(2933BF81-7B36-11d2-B20E-00C04F983E60), // IID_IXMLDOMDocument
    odl, 
    dual,
    oleautomation,
    nonextensible,
    pointer_default(unique)
]
				
Additionally, the XML interfaces are all defined within an IDL "library" block. Interfaces must be located outside of the library block in order for MIDL to generate proxy/stub code.

↑ Back to the top


References

For additional information on COM threading models, click the article number below to view the article in the Microsoft Knowledge Base:
150777� INFO: Descriptions and Workings of OLE Threading Models
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

↑ Back to the top


Keywords: KB259004, kbprb, kbmsxmlnosweep

↑ Back to the top

Article Info
Article ID : 259004
Revision : 3
Created on : 5/11/2006
Published on : 5/11/2006
Exists online : False
Views : 362