Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why is dangerous the use of the New keyword in VB to create COM objects registrered under MTS ?

0
Posted

Why is dangerous the use of the New keyword in VB to create COM objects registrered under MTS ?

0

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

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123