Re: marshall interface needed?
"Alex Blekhman" <tkfx.REMOVE@yahoo.com> wrote in message
news:O1M6DtvlIHA.1052@TK2MSFTNGP05.phx.gbl
"George" wrote:
If call method on destination apartment through interface
pointer of
component of destination apartment directly is violation (bypass
the above
two methods)?
(for example, sharing raw interface pointer directly in global
variable and
call methods on interface pointer directly)
Yes, it is a violation of COM rules. You'll get an error if you do
such call.
Unfortunately, the problem is that you _won't_ get an immediate error in
this case. It's a direct call, so COM runtime is out of the picture and
doesn't have a chance to intervene. You are calling a component on a
thread it was not designed to be called on - which may appear to work
sometimes, and fail other times. For example, an STA component might end
up being called simultaneously on two threads, thus creating a race
condition it is not prepared to handle.
You may be thinking about a situation where a COM proxy pointer is being
passed across apartments without marshalling. A proxy does detect that
it's being called on a wrong thread, and reports an error. But a direct
COM pointer typically doesn't.
--
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