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: Visual Basic
Expertise: Advanced
Jun 29, 2000

Pass MTS Object References Safely Between Processes

SafeRef returns a reference to the context wrapper instead of a reference to the object itself. You should never pass a direct reference of a Microsoft Transaction Server (MTS) object to a client application. If you do, the client application can make a call on the MTS object without going through the context wrapper. This defeats the interception scheme set up by the MTS runtime. You should use the SafeRef function, which returns the outside world's view of an MTS object. Let's say you're writing a method implementation for an MTS object. In the method, you want to create an object of some class, then pass your own reference to the newly created object. To do this, you might write this code:
 
Dim pSomeClass As CSomeClass 
Set pSomeClass = New CSomeClass
pSomeClass.SomeMethod Me 
' Incorrect code
However, this code is incorrect under MTS. The child object—pSomeClass—can invoke method calls on your object without going through the context wrapper. You should never bypass the interception scheme set up by the MTS runtime. Instead, you should pass a reference to your object:
 
pSomeClass.SomeMethod SafeRef(Me)
' Correct code
By calling SafeRef, you allow the child object to establish a connection that passes through the context wrapper. This technique keeps things in line with what the MTS runtime expects. The Me keyword is the only valid parameter you can pass when calling SafeRef with Visual Basic.
Deepak Pant
 
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