Object Constructor String
COM+ allows you to pass a construction parameter to new instances of your component. This instance activation service has nothing to do with application scalability, JITA, or object pooling, and is nothing more than a neat service.
On your component’s Properties page, there is a properties
group named “Object construction” on the Activation tab.
Once you enable this service (by checking the “Enable object
construction” checkbox), you can specify a string in free form.
Every instance of your component has access to this one string (you
cannot specify a string per instance). Because calls to
CoCreateInstance( )
or CreateObject( )
do not accept initialization parameters, you have to work
to gain access to the constructor string.
The first thing you need to do (besides enable the service) is have
your component implement an interface called
IObjectConstruct
, defined as:
interface IObjectConstruct : IUnknown { HRESULT Construct([in]IDispatch* pConstructionObj); };
If you enable object construction but do not implement the interface,
all client attempts to create a new instance of your component will
fail, showing the error code
E_NOINTERFACE
. They will fail because COM+ will
refuse to hand over to the client an object that could not be
initialized properly. IObjectConstruct
has only
one method, Construct( )
,
which COM+ uses to pass in a pointer to another interface called
IObjectConstructString
, defined as:
interface IObjectConstructString : IDispatch { ...
Get COM & .NET Component Services now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.