proxy/stub woes
- From: "Jason S" <jmsachs@xxxxxxxxx>
- Date: 16 Jan 2007 09:39:19 -0800
I have some vague uncertainties about getting things to work between
apartments when there are interfaces that are not IDispatch-derived.
Are there any good simple examples out there showing servers/clients in
separate build trees working together with interfaces derived from
IUnknown, and Good Practices for sharing the interface pointer type
definitions? (e.g. use #import?)
Here's my case:
(some information below abbreviated -- I am trying to include the
relevant info)
I have Server SPROC which is an .exe server.
I have Server SLOCAL which is a .dll server.
SLOCAL implements interface Ibatch using coclass Cbatch.
SPROC implements interface Ibatch_generator using coclass
Cbatch_generator.
Ibatch_generator has a get/put property called "data" which accepts an
interface pointer to Ibatch. If you call put_data(), it stores away the
(marshalled) interface pointer in a smart-pointer. If you call
get_data(), it retrieves the interface pointer, and if it's NULL, it
attempts to CoCreate() an Ibatch locally. This gives me the choice
whether to have the Cbatch residing within the apartment on the server
SLOCAL running within SPROC, or the server SLOCAL running within a
client (or through someone else's implementation of Ibatch, but forget
about that one).
Both Ibatch and Ibatch_generator are derived from IUnknown and are
defined in a base .idl file for which I am creating a proxy/stub .dll .
I have client C1 which instantiates the Ibatch_generator *, and based
on a command-line switch, it either calls get_data() to obtain the
Ibatch *, or it creates a Ibatch * itself and then calls put_data() to
share that with the Ibatch_generator. This way I can control in which
apartment the Ibatch resides.
Case 1: Ibatch_generator creates Ibatch *.
If Ibatch * resides within SLOCAL running within SPROC, everything
works great (as far as I can tell).
Case 2: C1 creates Ibatch *.
If Ibatch * resides within SLOCAL running within C1, I'm not so sure...
C1 calls methods of Ibatch_generator (running within SPROC) which then
call methods Ibatch::setup() (running within SLOCAL running in C1) and
I'm still debugging one method call (found an insidious problem where I
was using BSTR b = L"something" in a method call, and the proxy/stub
marshalling code didn't appear to like BSTRs which aren't properly
prefixed with their length, but there's something else wrong...)
In the IDL file, if I have Ibatch declared as "oleautomation" things
work OK, but if I leave that out, then I get some errors (still trying
to debug that), and I don't understand why.
.
- Follow-Ups:
- Re: proxy/stub woes
- From: Brian Muth
- Re: proxy/stub woes
- Prev by Date: Re: inheriting the VC++ template classes into C#.net
- Next by Date: Re: Tracing CComBSTR leaks
- Previous by thread: Cookies and multiple sessions
- Next by thread: Re: proxy/stub woes
- Index(es):
Relevant Pages
|