|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Simple ATL callback
From: Charles Gamble (Charles.Gamble
SINGULARITY.CO.UK)
Date: Tue Oct 26 2004 - 11:25:07 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I want to create a simple callback method called by a COM+ DLL server.
The method will be on an object implemented by a C++ client.
I have managed to get it to work for an in-process COM DLL, but as soon as I
put the server object into COM+, I am getting E_NOINTERFACE when doing a
QueryInterface.
I think it is because I have created an internal object in the C++ client.
I have done the following:
1. Added the below interface definition to COM+ DLL IDL:
[
object,
//use guidgen to generate a unique id
uuid(43FF9A45-33E4-4c56-BFE0-CDAEF5058F36),
dual,
helpstring("IClientCallback Interface"),
pointer_default(unique)
]
interface IClientCallback :IDispatch
{
[id(1), helpstring("method TestMethod")]
HRESULT TestMethod();
};
2. Created a C++ class that implements the interface in the C++ client:
class CClientCallback :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IClientCallback, &IID_IClientCallback,
&LIBID_AWSERVERLib>
{
public:
CClientCallback();
BEGIN_COM_MAP(CClientCallback)
COM_INTERFACE_ENTRY(IClientCallback)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
STDMETHOD(TestMethod)();
.......
3. I pass in the object to the server object method as follows (as a VARIANT
[in])
CComObject<CClientCallback>* pClientCallback = NULL;
hr = CComObject<CClientCallback>::CreateInstance(&pClientCallback);
CHECKHR(hr)
VARIANT vClientCallback;
V_VT(&vClientCallback) = VT_DISPATCH;
V_DISPATCH(&vClientCallback) = (IDispatch*)pClientCallback;
4. Then I query for the interface on the server:
CComPtr<IClientCallback> pClientCallback = NULL;
hr = V_DISPATCH(&i_vClientCallback)->QueryInterface(IID_IClientCallback,
(void **)&pClientCallback) ;
CHECKHR(hr)
hr = pClientCallback->TestMethod();
CHECKHR(hr)
The query interface is failing as I've already described. What would I need
to do to make this work?
Thanks,
Charles Gamble.
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.html
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]