devxlogo

Don’t store object variables in the SPM

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).

See also  Small Business Strategies with Venmo
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist