Why is dangerous the use of the New keyword in VB to create COM objects registrered under MTS ?
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). As you know VB lets you use New to create Multiuse classes as well. Unfortunately the New keyword has a couple of drawbacks: 1) In the situation where the caller and the callee are in the same EXE/DLL COM component VB perform an internal creation of the COM object bypassing the COM run-time (and the MTS run-time if the object is registered under MTS). While this fact is not a problem under out-of-MTS development, the situation gets very dangerous under MTS. What happens is that, since MTS is not notified of the object creation, the newly created object gets access to the ObjectContext of the father and MTS sees the code running inside method calls of the child object as “inline-code” of the father. I leave as an excercise to the reader what can happen if the child object calls SetComplete (against the ObjectContext of the father). 2) When