Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB7
Expertise: Intermediate
Dec 10, 2002



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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

Public Class BankTransfer
    Inherits ServicedComponent

    Protected Overrides Sub Construct(ByVal s As String)
        ' the argument contains the constructor string
    End Sub
End 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:

<ConstructionEnable(True, Default:="your default constructor string")> 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.
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date