returning COM objects in a COM object Call in an Outproc Server

returning COM objects in a COM object Call in an Outproc Server

Post by Fernando Sala » Tue, 09 Jul 2002 14:43:54



Hi:

I have the following problem:

I'm developing a COM server(EXE) that have multiple COM
objects, now, this server has(and exposes) a COM object of
class A and an Array of instances of COM objects of class B
(created by the server).

I understand the basis of instantiating a normal COM
object,etc. What I cannot find how to do is to implement a
method of class A that returns one of the instances of
class B that the server has. A parameter on that call
indicates one of the Class B instances is to be returned.

Is that as easy as return a pointer to the IUnknown of the
Class B instances, I'm not sure if it will be correctly
marshaled.

please answer also to my email if u can

Thanx in advance

Fernando

 
 
 

returning COM objects in a COM object Call in an Outproc Server

Post by John Dudd » Wed, 10 Jul 2002 02:02:48


It should be marshalled OK. If the server process is on a separate machine
AND you are using custom interfaces, you need to make sure you register the
proxy/stub DLL on the client machines as well.
But remember, what you get in the client will be a proxy to the object that
exists in the server process. All calls to it will be proxied to the server
process, and when that process goes away, your references to that object
will become invalid.

Is that what you wanted, or did you want something like Marshal by Value
(MBV) ?

JD


Quote:> Hi:

> I have the following problem:

> I'm developing a COM server(EXE) that have multiple COM
> objects, now, this server has(and exposes) a COM object of
> class A and an Array of instances of COM objects of class B
> (created by the server).

> I understand the basis of instantiating a normal COM
> object,etc. What I cannot find how to do is to implement a
> method of class A that returns one of the instances of
> class B that the server has. A parameter on that call
> indicates one of the Class B instances is to be returned.

> Is that as easy as return a pointer to the IUnknown of the
> Class B instances, I'm not sure if it will be correctly
> marshaled.

> please answer also to my email if u can

> Thanx in advance

> Fernando


 
 
 

1. How to return a com object from a function in another com object?

I have the following problem:

STDMETHODIMP CGDatabase::get_GTableDefs(GTableDefs ** pVal)
{
 // TO DO: Return GTableDefs collection
 HRESULT hr;

 CComObject<CGTableDefs> * TDefs;
 hr = CComObject<CGTableDefs>::CreateInstance(&TDefs);

 if (SUCCEEDED(hr)){ hr = TDefs->QueryInterface(__uuidof
(GTableDefs),(void**)&pVal);
 }
 return hr;

This compiles but doesn't work.
How do I have to return the GTableDefs ** pVal ???

Thanks
Daniel

2. option query-source

3. Have one COM object return handle to another COM object

4. How to import RAM/ROM into Composer and Silicon Ensemble

5. COM EXE Server Calling COM DLL Object Threading Problem

6. Screen Res (coping with different ones)

7. atl com object which method's param is an com object.

8. My first uncopyable CD?

9. Passing COM objects as parameters to other COM objects

10. COM Add-Ins publications

11. Events and COM add-ins

12. ECF files and COM add-ins