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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Advanced
Jun 29, 2000

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date