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.

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

Overview

Recent Articles: