Microsoft KB Archive/178845

= PRB: Use IDispatch for Objects Created by a DataSpace Object =

Article ID: 178845

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft Remote Data Services 1.5
 * Remote Data Service for ADO 2.0
 * Microsoft Remote Data Services 2.1
 * Remote Data Service for ADO 2.5
 * Remote Data Service for ADO 2.6

-



This article was previously published under Q178845



SYMPTOMS
Remote Data Services (RDS) has a DataSpace object that creates COM objects on a remote Internet Information Server (IIS) computer. The DataSpace's CreateObject call accepts a ProgID as well as the Universal Resource Identifier (URL) for an IIS server. CreateObject returns a variant that contains the IDispatch * for the created object.

If QueryInterface is called to get an interface other than IDispatch, E_NOINTERFACE is returned.



CAUSE
All calls to methods of the object created by DataSpace.CreateObject must be made through IDispatch::Invoke. Furthermore, you must call GetIDsOfNames to get the DISPIDs of the methods you want to call because RDS changes the values of the DISPIDs. They may be different from the IDs specified in the typelib.



RESOLUTION
The Visual C++ code sample shown below in the "More Information" section demonstrates how to call methods of a remote object created with RDS. The sample uses the Visual C++ 5.0 #import feature to generate C++ classes for calling methods of the DataSpace object and the remote object, which in this case is an RDS DataFactory.

The sample code shows calling the undocumented function _com_dispatch_method, which is a function of the C run-time library. As an alternative, IDispatch::Invoke can be called directly without the use of this helper function.

Here is a short description of the function:

HRESULT __cdecl _com_dispatch_method(IDispatch * pDisp, DISPID dispid, WORD w, VARTYPE vt, void * pResult, const wchar_t * szFormat, ...);

  pDisp    - IDispatch of the method's object. dispid  - The DISPID of the method to call. w       - Always DISPATCH_METHOD. vt      - The return type. Must be a Variant type. pResult - Pointer to the memory location to place the return value. SzFormat - String where each byte represents the variant type of each of the arguments being passed to the method.

The method contains a variable number of arguments because szFormat is followed by the arguments that you are passing to the object's method.



STATUS
This behavior is by design.



MORE INFORMATION
Additional query words: interface nointerface kbdse

Keywords: kbdatabase kbprb kbcode KB178845

-

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

© Microsoft Corporation. All rights reserved.