CoEnterServiceDomain function

Used to enter code that can then use COM+ services.

Syntax


HRESULT __stdcall CoEnterServiceDomain(
  _In_ IUnknown *pConfigObject
);

Parameters

pConfigObject [in]

A pointer to the IUnknown interface of the object, created from the CServiceConfig class, that contains the configuration information for the services to be used within the enclosed code.

Return value

This method can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_FAIL, as well as the following values.

Return codeDescription
S_OK

The method completed successfully.

CO_E_SXS_CONFIG

The side-by-side assembly configuration of the CServiceConfig object is invalid.

CO_E_THREADPOOL_CONFIG

The thread pool configuration of the CServiceConfig object is invalid. The thread apartment model cannot be reconfigured by calling CoEnterServiceDomain.

CO_E_TRACKER_CONFIG

The tracker configuration of the CServiceConfig object is invalid.

COMADMIN_E_PARTITION_ACCESSDENIED

The caller does not have access permissions for the COM+ partition.

 

Remarks

Code that is enclosed between calls to CoEnterServiceDomain and CoLeaveServiceDomain runs in its own context and behaves as though it were a method that is called on an object created within the context. CoEnterServiceDomain cannot switch to a different apartment model, so the enclosed code runs in the caller's apartment and on the caller's thread. It is an error to try to change the apartment model through the CServiceConfig object when calling CoEnterServiceDomain.

CoEnterServiceDomain first creates a context that is configured as specified by the CServiceConfig object that is passed as the pConfigObject parameter. Policies on both the client and server sides are then triggered as if a method call had occurred. The new context is then pushed onto a context stack and becomes the current context.

Because of their efficient design and because no thread marshaling is involved, using CoEnterServiceDomain and CoLeaveServiceDomain involves significantly reduced overhead as compared to an equivalent method call.

CoEnterServiceDomain and CoLeaveServiceDomain are particularly useful in applications, which can use these functions to access COM+ services without needing to create a component to do so.

The CoEnterServiceDomain and CoLeaveServiceDomain pairs can be nested.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

ComSvcs.h

Library

ComSvcs.lib

DLL

ComSvcs.dll

See also

CoCreateActivity
CoLeaveServiceDomain
COM+ Services Without Components
CServiceConfig

 

 

Community Additions

ADD
Show: