Limitations of Outgoing Calls

Besides the errors that message filtering might generate, COM places a few other restrictions on outgoing calls from any process to an object in any other process, as described in the following error list:

RPC_E_CANTCALLOUT-_INASYNCCALL

An object cannot make other outgoing calls while processing an asynchronous call to itself. See the discussion that follows this table for more information.

RPC_E_CANTCALLOUT-_ININPUTSYNCCALL

An object cannot make other outgoing calls while processing an input-synchronous call itself.

RPC_E_CANTCALLOUT-_INEXTERNALCALL

It is illegal to call out while inside a message filter.

RPC_E_CANTCALLOUT-_AGAIN

There is no second outgoing call on a DDE channel, used when communicating with an OLE version 1 server (OLE Documents only).


We will encounter a few of these as we progress through other subjects in this book, especially RPC_E_CANTCALLOUT_INASYNCCALL, which you will probably encounter in your own work at some time or other. The reason for this restriction is that the source of an asynchronous call is usually making a series of such calls to potentially multiple sinks. That source might also make a synchronous call after it has completed making asynchronous calls, expecting that it will not receive any incoming calls in the meantime. In such a case, the receiver (sink) of the asynchronous call is not allowed to make a synchronous call to the source. This avoids problems in which the sink calls back to the source but the source rejects the call. The sink can then go into a retry loop, during which time the source tries another asynchronous call to the same sink. These calls fail now that the sink is blocked. If the source itself goes into a retry loop, we get deadlocked. Not good. This means that you cannot make a call from within an asynchronous call—instead, you'll need to post yourself a message to make that call later.