Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Intermediate
Jun 18, 1999

Use CreateInstance Compared to CreateObject and New in MTS

The New keyword in VB is used to create a new instance of a class as an object for use within the current application. When used in a component within Microsoft Transaction Server (MTS), it creates a Private instance of an object that MTS knows nothing about. It won't have its own context object, and won't be included within the current transaction. In other words, it has to look after itself with no help from MTS. The CreateObject method is almost exactly the opposite. When used in a component running within MTS, this method creates a new instance of an object that MTS will treat as separate from the current component instance and it will get its own context object. However, the new instance will not contain any information from the context of the component that created this new instance, so it will run outside the current transaction. The CreateInstance method of the context object provides a solution to these two problems. It creates a new instance of the referenced component and provides it with a new context object. However, it also copies the transaction information from the context of the object that created it into the new context thus making it part of the current transaction. Therefore, you should use CreateInstance as opposed to CreateObject and New as it is more versatile in MTS environment.
Jai Bardhan
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date