HOWTO: Using COM+ 1.0 Constructor Strings from Visual Basic
ID: Q246138
|
The information in this article applies to:
-
Microsoft COM+, version 1.0
SUMMARY
COM+ 1.0 Provides the ability to administratively specify a string that will be passed to your object just after its creation and before any other method is invoked. This article explains how to specify this string and how to retrieve it in your object.
MORE INFORMATION
To specify a constructor string:
- Make sure your object is configured within a COM+ application.
- In the Component Services snap-in navigate to your component by right-clicking the component and selecting Properties.
- In the Activation tab select "Enable Object Construction" and type the string in the Constructor String text box. This may be a DSN, the name of some computer or queue, or some other information that your application needs to function that is administration-related.
To retrieve this string in your object, it must expose a certain interface called IObjectConstruct. To do so:
- Make sure your project has a reference to "COM+ 1.0 Services Type Library".
- In your class module, beneath any Option statements, add the following line of code:
Implements IObjectConstruct
You may also add a private class-level variable to hold the string:
Private msConstructorString As String
- In the scope list box in your code editor, where it reads "(General)", you should have a new item called IObjectConstruct. When you select it the IObjectConstruct_Construct function will be added to your class.
- Add the following code to it so the function looks as follows:
Private Sub IObjectConstruct_Construct(ByVal pCtorObj As Object)
msConstructorString = pCtorObj.ConstructString
End Sub
This retrieves the ConstructString and stores it in your private variable.
REFERENCES
For more detailed information on COM+ 1.0 see the following:
MSDN articles on Constructor Strings
Additional query words:
Visual Basic Constructor Strings COM+ COM Configure IObjectConstruct pCtorObj
Keywords : kbCOMPlus kbCOMt kbOOP kbSDKPlatform kbVBp600 kbCOMPlusAdmin
Version : :1.0
Platform : WINDOWS
Issue type : kbhowto