Microsoft KB Archive/250865

= INFO: CreateObject and CreateInstance Have the Same Effect in COM+ =

Article ID: 250865

Article Last Modified on 12/5/2007

-

APPLIES TO


 * Microsoft COM+ 1.0
 * Microsoft COM+ 1.5

-



This article was previously published under Q250865



SUMMARY
In Microsoft Transaction Server (MTS), you must use ObjectContext.CreateInstance in your root object to create secondary objects for the transaction to flow. In COM+ this still works, but it is no longer necessary to do it. In COM+, CreateObject subsumes the functionality of ObjectContext.CreateInstance. The object created participates in the caller's activity.

In COM+, you can use the standard CreateObject function in Microsoft Visual Basic to flow a transaction to secondary objects as appropriate.

The following example shows how the root object (clsRoot) creates the secondary object (clsSec) from within a transactional object. Sub Test Dim objSec As clsSec 'clsSec is the secondary class. Set objSec = CreateObject ("prjTest.clsSec") End Sub Also note that in COM+, as opposed to Microsoft Transaction Server, you don't have to obtain the ObjectContext in this particular scenario. This applies to CoCreateInstance and CoCreateInstanceEx APIs in C++ also.

Keywords: kbinfo KB250865

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.