Re: ATL and object aggregation (more)
- From: "Olivier" <toon@xxxxxxxxxxxxx>
- Date: Thu, 25 Aug 2005 10:18:27 +0200
Hi Alexander,
I will look at in-depth to IMarshal, but from what I know of marshalling, I
will not expect to find a solution from it for our problem...
Thanks
Olivier
"Alexander Nickolov" <agnickolov@xxxxxxxx> a écrit dans le message de news:
e1f7N4MqFHA.3108@xxxxxxxxxxxxxxxxxxxxxxx
> Without going into deep detail of your situation, it appears clear
> that you need custom marshaling. See IMarshal.
>
> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD
> email: agnickolov@xxxxxxxx
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================
>
> "Olivier" <toon@xxxxxxxxxxxxx> wrote in message
> news:esdXwOMqFHA.820@xxxxxxxxxxxxxxxxxxxxxxx
>> Igor,
>>
>>> Be aware that aggregation does not work across apartment boundaries
>>> (including process boundaries).
>>
>> I'm now aware and... unhappy :(
>>
>> So, for instance, we can't aggregate different STA objects from the same
>> inproc server? (I admit that I'm yet sometimes disturbed about COM
>> apartment and model threading...)
>>
>> Is there any error code returned (or exception thrown by ATL) if we do
>> the aggregation incorrectly? or just some strange behavior like the one I
>> encountered with FinalRelease() (argh!) ?
>>
>>> Why don't you simply marshal InObj3's interface pointer into the client
>>> process and have a real COM-created proxy?
>>
>> Because we need to create an instance of OutObj BEFORE we can have access
>> to InObj3 AND our client must be unaware of this (i.e it is not possible
>> for our client to make a simple and direct CoCreateInstance() call to
>> obtain an InObj3 running in the same process than OutObj). Moreover,
>> OutObj is a 'foreign' application that does not implement the interface
>> required by our client application so we created an OutObj add-in that
>> implements this required interface (and so, InObj1, InObj2 and InObj3
>> come in play here). InObj1 is the only object that our client must create
>> (In this scenario, InObj1 is like a surrogate or proxy object that hides
>> implementation details).
>>
>>> Why do you feel the need for your "fake" hand-written proxy? Why have an
>>> "acts like proxy" object when you can have the real thing?
>>
>> (Oups, here I made reference to the proxy design pattern)
>>
>> The answer is, because of performance issue...
>>
>> InObj3 implementation makes a lot of call in OutObj. In our first design,
>> InObj3 rans in the same process than our client application and it was
>> very-very slow: when InObj3 runs out-of-process of OutObj, the task that
>> it accomplishes takes ~160s, when it runs in-process of OutObj the same
>> task takes only ~4s. (yes, 40 times faster)
>>
>> Finally InObj3 implements several interfaces, and, although the
>> delegation solution does not seem very 'productive', it just seems to be
>> the only one usable...
>>
>> Thanks
>>
>> Olivier.
>>
>>
>> "Igor Tandetnik" <itandetnik@xxxxxxxx> a écrit dans le message de news:
>> OyKQ%23NLqFHA.2364@xxxxxxxxxxxxxxxxxxxxxxx
>>> Olivier <toon@xxxxxxxxxxxxx> wrote:
>>>> - I have an InObj1 in an inproc-server dll (InProc). This InObj1 is
>>>> used (created) by my client application,
>>>> - In the FinalConstruct() method of this InObj1, I create an instance
>>>> of an out-of-process object 'OutObj',
>>>> - Using one of the OutObj' methods I retrieve an instance of an object
>>>> InObj2 (instanced by OutObj when it starts). InObj2 is also located in
>>>> InProc,
>>>> - InObj2 exposes a CreateInstance() method that takes an IUnknown*
>>>> input argument and creates an instance of an object InObj3 also
>>>> located in InProc. In the implementation code of the CreateInstance()
>>>> method I create an instance of InObj3 with the code below (see: In
>>>> 'InObj3.cpp')
>>>> The reason of this architecture is to force InObj3 to run in the same
>>>> process than OutObj, for performance related issue (i.e avoid a lot
>>>> of RPC calls between my client application and OutObj) and to expose
>>>> all inerfaces implemented by InObj3 at the InObj1 level (InObj1 now
>>>> acts like a 'proxy' object to InObj3/OutObj)
>>>
>>> Be aware that aggregation does not work across apartment boundaries
>>> (including process boundaries).
>>>
>>> Why don't you simply marshal InObj3's interface pointer into the client
>>> process and have a real COM-created proxy? Why do you feel the need for
>>> your "fake" hand-written proxy? Why have an "acts like proxy" object
>>> when you can have the real thing?
>>>
>>> If for some reason you insist on having an InObj1 as an intermediary,
>>> your only option is delegation. InObj1 has to implement the same
>>> interfaces as InObj3, by simply forwarding every method call to InObj3.
>>>
>>>> Since InObj3 is aggregated by InObj1
>>>
>>> It's not. Again, COM aggregation cannot possibly work across apartment
>>> boundaries.
>>> --
>>> With best wishes,
>>> Igor Tandetnik
>>>
>>> With sufficient thrust, pigs fly just fine. However, this is not
>>> necessarily a good idea. It is hard to be sure where they are going to
>>> land, and it could be dangerous sitting under them as they fly
>>> overhead. -- RFC 1925
>>>
>>>
>>
>>
>
>
.
- Follow-Ups:
- Re: ATL and object aggregation (more)
- From: Alexander Nickolov
- Re: ATL and object aggregation (more)
- References:
- ATL and object aggregation
- From: Olivier
- Re: ATL and object aggregation
- From: Igor Tandetnik
- Re: ATL and object aggregation (more)
- From: Olivier
- Re: ATL and object aggregation (more)
- From: Igor Tandetnik
- Re: ATL and object aggregation (more)
- From: Olivier
- Re: ATL and object aggregation (more)
- From: Alexander Nickolov
- ATL and object aggregation
- Prev by Date: Re: {719C3050-F9D3-11CF-A493-00400523A8A0}
- Next by Date: Re: ATL and object aggregation (more)
- Previous by thread: Re: ATL and object aggregation (more)
- Next by thread: Re: ATL and object aggregation (more)
- Index(es):
Relevant Pages
|
Loading