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 resides the SPM will blindly pass you the rough interface pointer without marshaling it, thus violating COM rules (and your app will randomly fail). Park the interface pointer in the GIT and park the GIT cookie in the SPM.

This tip is taken from the FAQ list that Enrico mantains at his own home page (www.sabbasoft.com/mts_faq.htm).

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: