Configuring COM+ Services with CServiceConfig
The CServiceConfig class is used to configure the COM+ services that can be used without components. It aggregates the free-threaded marshaler, so it can be used in different apartments. To configure an individual service, you must call QueryInterface for the interface associated with the service and then call methods on that interface to establish the appropriate configuration. The following table describes the interfaces that are implemented through the CServiceConfig class.
Interface | Description |
---|---|
IServiceInheritanceConfig |
The default interface for the class. It is used to quickly initialize many of the COM+ services. |
IServiceComTIIntrinsicsConfig |
Used to configure the COM Transaction Integrator (COMTI) intrinsics information. COMTI allows developers to integrate mainframe-based transaction programs with component-based applications. |
IServiceIISIntrinsicsConfig |
Used to configure the Internet Information Services (IIS) intrinsics information. |
IServicePartitionConfig |
Used to configure how COM+ partitions are used with the services. |
IServiceSxSConfig |
Used to configure side-by-side assemblies. |
IServiceSynchronizationConfig |
Used to configure COM+ synchronization services. |
IServiceThreadPoolConfig |
Used to configure the thread pool for the COM+ service. The thread pool can be configured only when using the CoCreateActivity function. |
IServiceTrackerConfig |
Used to configure the Tracker property. Tracker is a reporting mechanism used by monitoring code to watch which code is running when. |
IServiceTransactionConfig |
Used to configure the COM+ transaction service. |
Component Services Administrative Tool
Does not apply.
Visual Basic
Does not apply.
C/C++
The following code fragment illustrates how to create and configure a CServiceConfig object to use COM+ transactions.
// Create a CServiceConfig object.
HRESULT hr = CoCreateInstance(CLSID_CServiceConfig, NULL, CLSCTX_INPROC_SERVER,
IID_IUnknown, (void**)&pUnknownCSC);
if (FAILED(hr)) throw(hr);
// Query for the IServiceInheritanceConfig interface.
hr = pUnknownCSC->QueryInterface(IID_IServiceInheritanceConfig,
(void**)&pInheritanceConfig);
if (FAILED(hr)) throw(hr);
// Inherit the current context before using transactions.
hr = pInheritanceConfig->ContainingContextTreatment(CSC_Inherit);
if (FAILED(hr)) throw(hr);
// Query for the IServiceTransactionConfig interface.
hr = pUnknownCSC->QueryInterface(IID_IServiceTransactionConfig,
(void**)&pTransactionConfig);
if (FAILED(hr)) throw(hr);
// Configure transactions to always create a new one.
hr = pTransactionConfig->ConfigureTransaction(CSC_NewTransaction);
if (FAILED(hr)) throw(hr);
// Set the isolation level of the transactions to ReadCommitted.
hr = pTransactionConfig->IsolationLevel(
COMAdminTxIsolationLevelReadCommitted);
if (FAILED(hr)) throw(hr);
// Set the transaction time-out to 1 minute.
hr = pTransactionConfig->TransactionTimeout(60);
if (FAILED(hr)) throw(hr);