Passing interface pointer across process space 
Author Message
 Passing interface pointer across process space

Hi,

I have made a COM object that can return an interface pointer to another
object. It works fine if this is implemented in a DLL. Is this also
possible if my COM object is in a stand alone executable, and the client
who receives the interface pointer is in another exe? So, can you pass
an interface pointer across your process space?

Thanks,
R. Moolenaar

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Tue, 17 Dec 2002 03:00:00 GMT  
 Passing interface pointer across process space



Quote:
>Hi,

>I have made a COM object that can return an interface pointer to
another
>object. It works fine if this is implemented in a DLL. Is this also
>possible if my COM object is in a stand alone executable, and the
client
>who receives the interface pointer is in another exe? So, can you
pass
>an interface pointer across your process space?

Yes, it is possible. COM/DCOM do it for you (MARSHALLING).

Martin



Tue, 17 Dec 2002 03:00:00 GMT  
 Passing interface pointer across process space


Quote:



> >Hi,

> >I have made a COM object that can return an interface pointer to
> another
> >object. It works fine if this is implemented in a DLL. Is this also
> >possible if my COM object is in a stand alone executable, and the
> client
> >who receives the interface pointer is in another exe? So, can you
> pass
> >an interface pointer across your process space?

> Yes, it is possible. COM/DCOM do it for you (MARSHALLING).

> Martin

My client exe is actually asking for an array of interfaces, like this:

IMy2ndInterface** ppIMy2ndInterface = new IMy2ndInterface*[lSizeIn];
hr = pIMy1stInterface->getInterfaces(lSizeIn, &ppIMy1stInterface);

My server seems to be returning the proper interface pointers (return
code S_OK), but when the call is unmarshalled it returns with
0x80040155, which means 'Interface not registered' (REGDB_E_IIDNOTREG).
However, the interface is OK, other calls work fine. The problem must be
in this call.

Any suggestions?
Thanks in advance,

R. Moolenaar

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 17 Dec 2002 03:00:00 GMT  
 Passing interface pointer across process space
Show your IDL and server side implementation. Of specific
interest is your size_is attribute and the fact you don't derive
from IDispatch. Of course, you should check you have registered
your proxy/stub DLL...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:





> > >Hi,

> > >I have made a COM object that can return an interface pointer to
> > another
> > >object. It works fine if this is implemented in a DLL. Is this also
> > >possible if my COM object is in a stand alone executable, and the
> > client
> > >who receives the interface pointer is in another exe? So, can you
> > pass
> > >an interface pointer across your process space?

> > Yes, it is possible. COM/DCOM do it for you (MARSHALLING).

> > Martin

> My client exe is actually asking for an array of interfaces, like this:

> IMy2ndInterface** ppIMy2ndInterface = new IMy2ndInterface*[lSizeIn];
> hr = pIMy1stInterface->getInterfaces(lSizeIn, &ppIMy1stInterface);

> My server seems to be returning the proper interface pointers (return
> code S_OK), but when the call is unmarshalled it returns with
> 0x80040155, which means 'Interface not registered' (REGDB_E_IIDNOTREG).
> However, the interface is OK, other calls work fine. The problem must be
> in this call.

> Any suggestions?
> Thanks in advance,

> R. Moolenaar

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Tue, 17 Dec 2002 03:00:00 GMT  
 Passing interface pointer across process space
Here is the specific part of my IDL file:

[
        object,
        uuid(D997AECD-8266-43D7-99CA-11DBC4999302),
        helpstring("IMy1stInterface Interface"),
        pointer_default(unique)
]
interface IMy1stInterface : IUnknown
{
        HRESULT getInterfaces([in] long lSizeIn, [out, size_is(lSizeIn)]
IMy2ndInterface* ifaces[]);

Quote:
};

By the way, I made some typo's in my last reply. Here is my actual call:

IMy2ndInterface** ppIMy2ndInterface = new IMy2ndInterface*[lSizeIn];
HRESULT hr = pIMy1stInterface->getInterfaces(lSizeIn,
ppIMy2ndInterface);

Finally, the server-side implementation is like this:

STDMETHODIMP CMyClass::getInterfaces(long lSizeIn,
IMy2ndInterface* ifaces[])
{
        int i;

        list<IMy2ndInterface*>::iterator jbIt;
        for(jbIt = m_theIFaces.begin(), i = 0;
                        (jbIt != m_theIFaces.end()) && (i<lSizeIn);
jbIt++, i++)
        {
                ifaces[i] = *jbIt;
        }

        return S_OK;

Quote:
}

Thanks again,
R. Moolenaar



Quote:
> Show your IDL and server side implementation. Of specific
> interest is your size_is attribute and the fact you don't derive
> from IDispatch. Of course, you should check you have registered
> your proxy/stub DLL...

> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD

> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================




Quote:




> > > >Hi,

> > > >I have made a COM object that can return an interface pointer to
> > > another
> > > >object. It works fine if this is implemented in a DLL. Is this
also
> > > >possible if my COM object is in a stand alone executable, and the
> > > client
> > > >who receives the interface pointer is in another exe? So, can you
> > > pass
> > > >an interface pointer across your process space?

> > > Yes, it is possible. COM/DCOM do it for you (MARSHALLING).

> > > Martin

> > My client exe is actually asking for an array of interfaces, like
this:

> > IMy2ndInterface** ppIMy2ndInterface = new IMy2ndInterface*[lSizeIn];
> > hr = pIMy1stInterface->getInterfaces(lSizeIn, &ppIMy1stInterface);

> > My server seems to be returning the proper interface pointers
(return
> > code S_OK), but when the call is unmarshalled it returns with
> > 0x80040155, which means 'Interface not registered'

(REGDB_E_IIDNOTREG).

Quote:
> > However, the interface is OK, other calls work fine. The problem
must be
> > in this call.

> > Any suggestions?
> > Thanks in advance,

> > R. Moolenaar

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Fri, 20 Dec 2002 03:00:00 GMT  
 Passing interface pointer across process space
The code seems ok. Therefore, the question is - did you
build and register the proxy/stub DLL?

BTW, there's a subtle, but fatal nonetheless error in your
code. Call AddRef on the interface pointers stored in the
returned array:

Quote:
> ifaces[i] = *jbIt;

// Add this line:
ifaces[i]->AddRef();

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> Here is the specific part of my IDL file:

> [
> object,
> uuid(D997AECD-8266-43D7-99CA-11DBC4999302),
> helpstring("IMy1stInterface Interface"),
> pointer_default(unique)
> ]
> interface IMy1stInterface : IUnknown
> {
> HRESULT getInterfaces([in] long lSizeIn, [out, size_is(lSizeIn)]
> IMy2ndInterface* ifaces[]);
> };

> By the way, I made some typo's in my last reply. Here is my actual call:

> IMy2ndInterface** ppIMy2ndInterface = new IMy2ndInterface*[lSizeIn];
> HRESULT hr = pIMy1stInterface->getInterfaces(lSizeIn,
> ppIMy2ndInterface);

> Finally, the server-side implementation is like this:

> STDMETHODIMP CMyClass::getInterfaces(long lSizeIn,
> IMy2ndInterface* ifaces[])
> {
> int i;

> list<IMy2ndInterface*>::iterator jbIt;
> for(jbIt = m_theIFaces.begin(), i = 0;
> (jbIt != m_theIFaces.end()) && (i<lSizeIn);
> jbIt++, i++)
> {
> ifaces[i] = *jbIt;
> }

> return S_OK;
> }

> Thanks again,
> R. Moolenaar



> > Show your IDL and server side implementation. Of specific
> > interest is your size_is attribute and the fact you don't derive
> > from IDispatch. Of course, you should check you have registered
> > your proxy/stub DLL...

> > --
> > =====================================
> > Alexander Nickolov
> > Microsoft MVP [VC], MCSD

> > MVP VC FAQ: http://www.mvps.org/vcfaq
> > =====================================







> > > > >Hi,

> > > > >I have made a COM object that can return an interface pointer to
> > > > another
> > > > >object. It works fine if this is implemented in a DLL. Is this
> also
> > > > >possible if my COM object is in a stand alone executable, and the
> > > > client
> > > > >who receives the interface pointer is in another exe? So, can you
> > > > pass
> > > > >an interface pointer across your process space?

> > > > Yes, it is possible. COM/DCOM do it for you (MARSHALLING).

> > > > Martin

> > > My client exe is actually asking for an array of interfaces, like
> this:

> > > IMy2ndInterface** ppIMy2ndInterface = new IMy2ndInterface*[lSizeIn];
> > > hr = pIMy1stInterface->getInterfaces(lSizeIn, &ppIMy1stInterface);

> > > My server seems to be returning the proper interface pointers
> (return
> > > code S_OK), but when the call is unmarshalled it returns with
> > > 0x80040155, which means 'Interface not registered'
> (REGDB_E_IIDNOTREG).
> > > However, the interface is OK, other calls work fine. The problem
> must be
> > > in this call.

> > > Any suggestions?
> > > Thanks in advance,

> > > R. Moolenaar

> > > Sent via Deja.com http://www.deja.com/
> > > Before you buy.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Fri, 20 Dec 2002 03:00:00 GMT  
 Passing interface pointer across process space
I found the problem in the dll, sorry I didn't find it earlier. I was
convinced that the dll had the proxy/stub code inside (using 'allow
merging proxy/stub code' in the Appwizard), but that was not the case.

Thanks for the advice,
R. Moolenaar



Quote:
> The code seems ok. Therefore, the question is - did you
> build and register the proxy/stub DLL?

> BTW, there's a subtle, but fatal nonetheless error in your
> code. Call AddRef on the interface pointers stored in the
> returned array:

> > ifaces[i] = *jbIt;
> // Add this line:
> ifaces[i]->AddRef();

> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD

> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================



> > Here is the specific part of my IDL file:

> > [
> > object,
> > uuid(D997AECD-8266-43D7-99CA-11DBC4999302),
> > helpstring("IMy1stInterface Interface"),
> > pointer_default(unique)
> > ]
> > interface IMy1stInterface : IUnknown
> > {
> > HRESULT getInterfaces([in] long lSizeIn, [out, size_is(lSizeIn)]
> > IMy2ndInterface* ifaces[]);
> > };

> > By the way, I made some typo's in my last reply. Here is my actual
call:

> > IMy2ndInterface** ppIMy2ndInterface = new IMy2ndInterface*[lSizeIn];
> > HRESULT hr = pIMy1stInterface->getInterfaces(lSizeIn,
> > ppIMy2ndInterface);

> > Finally, the server-side implementation is like this:

> > STDMETHODIMP CMyClass::getInterfaces(long lSizeIn,
> > IMy2ndInterface* ifaces[])
> > {
> > int i;

> > list<IMy2ndInterface*>::iterator jbIt;
> > for(jbIt = m_theIFaces.begin(), i = 0;
> > (jbIt != m_theIFaces.end()) && (i<lSizeIn);
> > jbIt++, i++)
> > {
> > ifaces[i] = *jbIt;
> > }

> > return S_OK;
> > }

> > Thanks again,
> > R. Moolenaar



> > > Show your IDL and server side implementation. Of specific
> > > interest is your size_is attribute and the fact you don't derive
> > > from IDispatch. Of course, you should check you have registered
> > > your proxy/stub DLL...

> > > --
> > > =====================================
> > > Alexander Nickolov
> > > Microsoft MVP [VC], MCSD

> > > MVP VC FAQ: http://www.mvps.org/vcfaq
> > > =====================================







> > > > > >Hi,

> > > > > >I have made a COM object that can return an interface pointer
to
> > > > > another
> > > > > >object. It works fine if this is implemented in a DLL. Is
this
> > also
> > > > > >possible if my COM object is in a stand alone executable, and
the
> > > > > client
> > > > > >who receives the interface pointer is in another exe? So, can
you
> > > > > pass
> > > > > >an interface pointer across your process space?

> > > > > Yes, it is possible. COM/DCOM do it for you (MARSHALLING).

> > > > > Martin

> > > > My client exe is actually asking for an array of interfaces,
like
> > this:

> > > > IMy2ndInterface** ppIMy2ndInterface = new

IMy2ndInterface*[lSizeIn];
Quote:
> > > > hr = pIMy1stInterface->getInterfaces(lSizeIn,

&ppIMy1stInterface);

- Show quoted text -

Quote:

> > > > My server seems to be returning the proper interface pointers
> > (return
> > > > code S_OK), but when the call is unmarshalled it returns with
> > > > 0x80040155, which means 'Interface not registered'
> > (REGDB_E_IIDNOTREG).
> > > > However, the interface is OK, other calls work fine. The problem
> > must be
> > > > in this call.

> > > > Any suggestions?
> > > > Thanks in advance,

> > > > R. Moolenaar

> > > > Sent via Deja.com http://www.deja.com/
> > > > Before you buy.

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Fri, 20 Dec 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Understanding reference counts on com objects passed across processes

2. Passing Arrays in ATL across an Exe(local process)

3. Passing Arrays in ATL across an Exe(local process)

4. Can't pass IIDs properly across process boundaries

5. Passing Socket handles across process boundaries??

6. Can't pass IIDs properly across process boundaries

7. Passing a Pointer to Pointer to an Interface

8. malloc space for passed array pointer?

9. Re : Interface pointers over process boundaries

10. getting interface pointer from another process..

11. Passing interface pointer

12. Passing interface pointer from VC++ to VB

 

 
Powered by phpBB® Forum Software