Platform SDK: Transaction Server

ITransactionContextEx.CreateInstance Method

[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]

Instantiates an MTS object that will execute within the scope of the transaction that was initiated with the creation of the TransactionContextEx object.

Provided By

ITransactionContextEx Interface

IUnknown CreateInstance (
    _Guid clsid,
    _Guid  iid,
);

Parameter

clsid
[in] A reference to the CLSID of the type of object to instantiate.

iid
[in] Any interface that's implemented by the object you want to instantiate.

Return Value

A reference to the IUnknown interface on a new instance of the MTS component specified in the clsid parameter.

Remarks

When a base client uses the ITransactionContextEx.CreateInstance method to instantiate an MTS object, the new object executes within the transaction context object's activity. If the transaction attribute of the new object's component is set to either Supports transactions or Requires a transaction, the new object also inherits the transaction initiated with the creation of the TransactionContextEx object. However, if the component that provides the new object has its transaction attribute set to Does not support transactions, the object neither inherits the transaction nor passes it on to objects it subsequently creates. If the component that provides the new object has its transaction attribute set to Requires a new transaction, the MTS run-time environment initiates a new transaction for the new object, and that transaction is the one that's inherited by objects it subsequently creates.

CreateInstance always returns the IUnknown interface on the newly instantiated object. You should immediately cast the returned value to the interface with which you want to communicate with the new object. The interface ID you pass in the iid parameter doesn't have to be the same interface to which you cast the returned value, but it must be an interface that's implemented by the object you want to instantiate.

MTS always uses standard marshaling. Even if a component exposes the IMarshal interface, its IMarshal methods will never be called by the MTS run-time environment.

Note You can't create MTS objects as part of an aggregation.

Example

See Also

Transaction Context Objects, Base Clients, Transactions, CreateInstance