Platform SDK: Transaction Server |
[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
HRESULT ITransactionContextEx::CreateInstance ( REFCLSID rclsid, REFIID riid, LPVOID FAR* ppvObj );
Parameter
rclsid
[in] A reference to the CLSID of the type of object to instantiate.
riid
[in] A reference to the interface ID of the interface through which you want to communicate with the new object.
ppvObj
[out] A reference to a new object of the type specified by the rclsid argument, through the interface specified by the riid argument.
Return Values
S_OK
A reference to the object is returned in the ppvObj parameter.
REGDB_E_CLASSNOTREG
The component specified by rclsid is not registered as a COM component.
E_OUTOFMEMORY
There's not enough memory available to instantiate the object.
E_INVALIDARG
The argument passed in the ppvObj parameter is invalid.
E_UNEXPECTED
An unexpected error occurred.
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.
If the Microsoft Distributed Transaction Coordinator is not running and the object is transactional, the object is successfully created. However, method calls to that object will fail with CONTEXT_E_TMNOTAVAILABLE. Objects cannot recover from this condition and should be released.
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. In this respect, using CreateInstance is comparable to using CoCreateInstance and specifying NULL for the controlling IUnknown interface (pUnkOuter).
See Also
Transaction Context Objects, Base Clients, Transactions, CreateInstance