Is it possible to know inside a server object (inproc) whether a call
was made through COM proxy, i.e. across apartments?
It is possible to know that there exist proxies on your object - just implement IExternalConnection. I can't think of any way to detect whether a particular call came from a direct client or through proxy. Why do you care?
--
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
Ok, thanks!
> Why do you care?
I thought of implementing CPs differently depending on whether the
object and its client are in the same apartment. Meanwhile I gave up
on that idea, but anyway it's good to know.
Ah, so you don't actually need to know whether you are called through a proxy - you need to know whether an interface pointer you are given (a sink pointer) is a direct pointer or a proxy. Query it for IMultiQI - if it supports that, chances are very high it's a proxy (it is theoretically possible for a direct object to implement IMultiQI, but there's no reason to do so).
IRpcOptions is another interface of this kind (implemented by COM runtime on all proxies, extremely unlikely to be implemented on direct objects).