Passing an interface pointer to the out of proc server. QueryInterface() problem 
Author Message
 Passing an interface pointer to the out of proc server. QueryInterface() problem

Hello everybody! I've got an ATL question for you.
I have a strange problem (at least it seems strange to me)
passing an interface pointer to an object, implemented in
the inproc server to the method of another object
implemented in the out of proc server.

Here is the situation I have:

1.
The first file I have is an out of proc server
(EXESRVR.EXE implemented in ATL) which IDL file
defines the following interfaces:

  IMyDataReader : IUnknown  {    HRESULT Read
(...);   ...  }  IMyDataStorage : IDispatch  {    //    //
pUnkReader parameter is the pointer to the IUnknown
interface    // of the object that implements a
IMyDataReader interface    //    [id(1)] HRESULT Store
([in]IUnknown* pUnkReader);    ...  }  

IMyDataStorage interface is implemented by CMyDataStorage
coclass which
also implements IDispatch, ISupportErrorInfo and
IConnectionPointContainer
interfaces. CMyDataStorage uses CComClassFactorySingleton.

IMyDataReader interface is defined but it is NOT
IMPLEMENTED !

2.
I also have an in proc server (DLLSRVR.DLL implemented in
ATL) which IDL file defines the
IMyDataWriter interface in the following way:

  interface IMyDataWriter : IDispatch  {    ...    [id(1)]
HRESULT Write (...);  }  

IMyDataWriter interface is implemented by the
CMyDataObject class which also
implements IDispatch, ISupportErrorInfo and IMyDataReader
interfaces.

3.
I have a client application (CLIENT.EXE implemented in
MFC) which eventualy calls the following code:

  ....  HRESULT hr;  CComPtr <IMyDataWriter> pWriter;  
CComPtr <IMyDataStorage> pStorage;  hr = pWriter-

Quote:
>CoCreateInstance (CLSID_MyDataObject);  if (FAILED

(hr))    // Handle Error...  hr = pStorage-
Quote:
>CoCreateInstance (CLSID_MyDataStorage);  if (FAILED

(hr))    // Handle Error...    // Write some data to the
object  pWriter->Write (data, data_size);    //  // Now I
will try to store the object  //  IUnknown *pUnk;  hr =
pWriter->QueryInterface (&pUnk); // get object's unknown  
if (FAILED (hr))    // Handle Error...  //  // Call the
function that should store the object's data.  //  hr =
pStorage->Save (pUnk);  pUnk->Release();  ... etc.  

HERE IS THE ACTUAL QUESTION:

The call to the pStorage->Save (pUnk) always fail because
when
the CMyDataStorage::Store() function calls pUnkReader-

Quote:
>QueryInterface (IID_IMyDataReader, (void**)&pReader)

if always returnes the E_NOINTERFACE error. What is
interesting is that calls to

pUnkReader->QueryInterface (IID_IDispatch, (void**)
&pDispatch) and
pUnkReader->QueryInterface (IID_ISupportErrorInfo, (void**)
&pErrorInfo)

DO NOT fail !

Does anybody have an idea of what is going on here?



Thu, 09 Sep 2004 13:45:04 GMT  
 Passing an interface pointer to the out of proc server. QueryInterface() problem
Looks like you haven't build or registered the proxy/stub libray for the
IMyDataReader interface. Your interface needs custom marshalling since it
isn't either a disp or dual interface. Launch nmake manually from the
command prompt giving it the <yourprojectname>_ps.mk file in the project
directory.

--
Frederic Claux



Quote:
> Hello everybody! I've got an ATL question for you.
> I have a strange problem (at least it seems strange to me)
> passing an interface pointer to an object, implemented in
> the inproc server to the method of another object
> implemented in the out of proc server.

> Here is the situation I have:

> 1.
> The first file I have is an out of proc server
> (EXESRVR.EXE implemented in ATL) which IDL file
> defines the following interfaces:

>   IMyDataReader : IUnknown  {    HRESULT Read
> (...);   ...  }  IMyDataStorage : IDispatch  {    //    //
> pUnkReader parameter is the pointer to the IUnknown
> interface    // of the object that implements a
> IMyDataReader interface    //    [id(1)] HRESULT Store
> ([in]IUnknown* pUnkReader);    ...  }

> IMyDataStorage interface is implemented by CMyDataStorage
> coclass which
> also implements IDispatch, ISupportErrorInfo and
> IConnectionPointContainer
> interfaces. CMyDataStorage uses CComClassFactorySingleton.

> IMyDataReader interface is defined but it is NOT
> IMPLEMENTED !

> 2.
> I also have an in proc server (DLLSRVR.DLL implemented in
> ATL) which IDL file defines the
> IMyDataWriter interface in the following way:

>   interface IMyDataWriter : IDispatch  {    ...    [id(1)]
> HRESULT Write (...);  }

> IMyDataWriter interface is implemented by the
> CMyDataObject class which also
> implements IDispatch, ISupportErrorInfo and IMyDataReader
> interfaces.

> 3.
> I have a client application (CLIENT.EXE implemented in
> MFC) which eventualy calls the following code:

>   ....  HRESULT hr;  CComPtr <IMyDataWriter> pWriter;
> CComPtr <IMyDataStorage> pStorage;  hr = pWriter-
> >CoCreateInstance (CLSID_MyDataObject);  if (FAILED
> (hr))    // Handle Error...  hr = pStorage-
> >CoCreateInstance (CLSID_MyDataStorage);  if (FAILED
> (hr))    // Handle Error...    // Write some data to the
> object  pWriter->Write (data, data_size);    //  // Now I
> will try to store the object  //  IUnknown *pUnk;  hr =
> pWriter->QueryInterface (&pUnk); // get object's unknown
> if (FAILED (hr))    // Handle Error...  //  // Call the
> function that should store the object's data.  //  hr =
> pStorage->Save (pUnk);  pUnk->Release();  ... etc.

> HERE IS THE ACTUAL QUESTION:

> The call to the pStorage->Save (pUnk) always fail because
> when
> the CMyDataStorage::Store() function calls pUnkReader-
> >QueryInterface (IID_IMyDataReader, (void**)&pReader)
> if always returnes the E_NOINTERFACE error. What is
> interesting is that calls to

> pUnkReader->QueryInterface (IID_IDispatch, (void**)
> &pDispatch) and
> pUnkReader->QueryInterface (IID_ISupportErrorInfo, (void**)
> &pErrorInfo)

> DO NOT fail !

> Does anybody have an idea of what is going on here?



Fri, 10 Sep 2004 19:10:19 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problems passing objects to in-proc C# COM server from VBS

2. Passing Interface pointer from local server to MFC app

3. Getting marshalled interface from 2nd out-of-proc server

4. Passing an in-proc pointer

5. Passing a Pointer to Pointer to an Interface

6. Converting In-Proc Server to out-Proce Server?

7. Passing interface pointer

8. Passing interface pointer from VC++ to VB

9. COM/ATL novice:passing object pointers through methods on a COM interface

10. proper way for passing com interface pointers

11. Can I pass the pointer of interface between the two threads

12. run time error when passing a pointer to struct for a dual interface

 

 
Powered by phpBB® Forum Software