devxlogo

Support COM+ constructor strings in serviced components

Support COM+ constructor strings in serviced components

Having a VB6 component support a COM+ construction string requires that you implement the IObjectConstruct interface and its only method, Construct. The .NET ServicedComponent class implements this interface internally and expose the Construct method as a protected, overridable method. Thus your VB.NET component can learn what constructor string has been passed to it in a very simple way:

Imports System.EnterpriseServicesPublic Class BankTransfer    Inherits ServicedComponent    Protected Overrides Sub Construct(ByVal s As String)        ' the argument contains the constructor string    End SubEnd Class

The Construct method is automatically invoked after the constructor method, provided that the “Enable object constructor” option is selected in the component’s Activation tab. To ease the installation step you can decorate the class with a ConstructionEnabled attribute, so that this option is automatically selected when the component is imported in a COM+ application:

 Public _    Class BankTransfer    '....End Class

The constructor string passed in the attribute is used to provide a default string for the corresponding field in the Activation tab, but in most cases it will be overwritten after the component is imported in the COM+ application. After the component has been imported, this attribute has no effect.

See also  Why ChatGPT Is So Important Today
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