The Call Object

In addition to providing a context object to represent the context of an object, COM+ creates a transient object called the call object each time that object is called. The transient call object represents the current call in progress. Objects can access their call object by calling CoGetCallContext( ) (see Figure 2-6). The CoGetCallContext( ) signature is defined as:

HRESULT CoGetCallContext(REFIID riid, void** ppInterface);

The call object only exists as long as a call from a client is in progress, and it is destroyed by COM+ after the called method returns. You should not cache a pointer to the call object as a member variable of your object because that pointer will be invalid once the method that saved it returns. Furthermore, if your object is doing work in the background—that is, no method call from the client is currently in progress—it will not have access to a call object. If you try to access a call object while a call is not in progress, CoGetCallContext( ) will fail and return the error code RPC_E_CALL_COMPLETE . You can, however, still access the context object, which exists as long as the context exists, and whose pointer can be cached by the objects associated with it.

The call object exposes two interfaces used to obtain information about the call security settings. These interfaces, discussed in Chapter 7, are ISecurityCallContext and IServerSecurity .

Figure 2-6.  When a method call is in progress, a COM+ object has access to the call object ...

Get COM & .NET Component Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.