Article ID: 250865 - Last Review: December 5, 2007 - Revision: 1.3

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

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q250865
Expand all | Collapse all

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.

APPLIES TO
  • Microsoft COM+ 1.0
  • Microsoft COM+ 1.5
Keywords: 
kbinfo KB250865