使用 CServiceConfig 配置 COM+ 服务
CServiceConfig 类用于配置无需组件即可使用的 COM+ 服务。 它会聚合自由线程封送处理器,因此可以在不同的单元中使用。 若要配置单个服务,必须为与服务关联的接口调用 QueryInterface,然后针对该接口调用方法,以建立适当的配置。 下表描述了通过 CServiceConfig 类实现的接口。
接口 | 说明 |
---|---|
IServiceInheritanceConfig |
类的默认接口。 它用于快速初始化许多 COM+ 服务。 |
IServiceComTIIntrinsicsConfig |
用于配置 COM 事务集成器 (COMTI) 内部函数信息。 COMTI 允许开发人员将基于大型机的事务程序与基于组件的应用程序集成。 |
IServiceIISIntrinsicsConfig |
用于配置 Internet Information Services (IIS) 内部函数信息。 |
IServicePartitionConfig |
用于配置将 COM+ 分区与服务结合使用的方式。 |
IServiceSxSConfig |
用于配置并行程序集。 |
IServiceSynchronizationConfig |
用于配置 COM+ 同步服务。 |
IServiceThreadPoolConfig |
用于为 COM+ 服务配置线程池。 仅当使用 CoCreateActivity 函数时,才能配置线程池。 |
IServiceTrackerConfig |
用于配置 Tracker 属性。 Tracker 是监视代码用来监视何时运行代码的报告机制。 |
IServiceTransactionConfig |
用于配置 COM+ 事务服务。 |
组件服务管理工具
不应用。
Visual Basic
不应用。
C/C++
以下代码片段演示如何创建和配置 CServiceConfig 对象,以使用 COM+ 事务。
// 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);