December 8, 2001

Don’t use global variables in MTS/COM+ projects

Public variables at module level are thread specific. Each new thread starts get a new fresh & uninitialized copy of such variables. All the activities that are born from the same object context always run in the same apartment (You can confirm this by checking the thread ID) as if

Don’t let binary compatibility beat you

When you decide to release a new version of an MTS/COM+ component you should take care of its compatibility with the previous version. There are three types of changes you could make:(1) You change only internal code of a component, keeping the interface that the component provides untouched.(2) You only

The best setting for the RunAs option in a server package

When you deploy COM objects in DLLs no security issues arise since DLLs run in the process of the caller. On the contrary, when you deploy your COM objects into an .EXE, you have to deal with such issues. – (D)COM needs to know under what security principal (read identity)

Misconceptions on variables and binding

Consider this line of code: Dim x as Project1.Class1 Many developers think that we were declaring x as a “Project1.Class1” object. This is wrong. All object variables in VB are interface variables. In this line of code x is declared as the _Class1 interface defined in the Project1 Type library

Never use New to create MTS/COM+ objects

A common question among VB developers is: Why is it dangerous the use of the New keyword in VB to create COM objects registered under MTS/COM+?The New keyword is the only way to go when you want to create objects that are defined as PublicNotCreatable or Private (CreateObject doesn’t work)

Don’t store object variables in the SPM

Some MTS/COM+ newbies wonder whether it is legal to store object variables in the SPM. No, you can’t!! the SPM is unaware of Apartment marshaling issues. If you ask the SPM for an interface pointer while running in an apartment that is different from the one where the interface pointer

Obtain a Regional Decimal Character without an API

Use this function to read a number decimal symbol from regional settings: Sub Form_Load()Dim DecS As StringDecS = ReadDecimalSymbol()End SubFunction ReadDecimalSymbol() As StringReadDecimalSymbol = Mid$(CStr(1.1), 2, 1)End Function

Authenticate Component Usage

Bundling functionality and program logic into an ActiveX DLL is an excellent form of encapsulation. But even when you expose functionality to your client application, you don