Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New or CreateObject while creating Transactional object

Status
Not open for further replies.

pankajv

Programmer
Jan 30, 2002
178
0
0
IN
I have 3 classes:
Class 1(Not an MTS Object)
Class 2(Requires Transaction)
Class 3(Supports Transaction)
All the three are part of one dll which is registered under MTS.
I have to test a simple roll back functionality, In which My class 3 is updating a database table and the class 2 should rollback the transaction. To do this I am creating the object of Class 2 in class 1 using the New operator and the object of Class 3 in class 2 using the CreateInstance method of ObjectContext object. I am calling the method of class 1 through some dummy method, which internally calls method of class 2 and that inetrnally calls method of class 3 to update the database. When I observe the MTS console I found that the object of class 1 and class 3 are getting creted but the object of class 2 is not getting created under MTS, which means the transaction is not getting rollbacked. When I created the object of class 2 using CreateObject everything worked perfectly fine.
Please tell me how New and CreateObject behave differently in MTS world and when to use which?
 
in MTS there is a clear difference.
NEW will NOT Envilope the new object in the current transaction object. If the new object requires a transaction then it will get its own new one created.

Under Component Services the NEW keyword and
GetObjectContext.CreateInstance("") I've read are supposed to work the same but from experiance NEW works as it always has, not including the new object in the current transaction.

I think you want GetObjectContext.CreateInstance("")
not CreateObject that will do the same as NEW.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top