COM+ Constructor String

Any COM+ configured component that implements the IObjectConstruct interface has access during construction to a construction string (discussed in Chapter 3), configured in the Component Services Explorer. Serviced components are no different. The base class, ServicedComponent , already implements the IObjectConstruct interface as a virtual method (it has only one method). Your derived serviced component can override the Construct( ) method, as shown in this code sample:

public class MyComponent :ServicedComponent
{ 
   public override void Construct(string constructString) 
   {     
      //use the string. For example:
      MessageBox.Show(constructString);      
   }
}

If the checkbox “Enable object construction” on the component Activation tab is selected, then the Construct( ) method is called after the component’s constructor, providing it with the configured construction string.

You can also enable construction string support and provide a default construction string using the ConstructionEnabled attribute:

[ConstructionEnabled(Enabled = true,Default = "My String")]
public class MyComponent :ServicedComponent
{ 
   public override void Construct(string constructString) 
   {...}
}

The ConstructionEnabled attribute has two public properties. Enabled enables construction string support for your serviced component in the Component Services Explorer (once the component is registered) and Default provides an initial string value. When your component is registered with COM+, the registration process ...

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.