Microsoft KB Archive/305745

= How To Alias a Component in COM+ 1.5 =

Article ID: 305745

Article Last Modified on 12/5/2007

-

APPLIES TO


 * Microsoft COM+ 1.5

-



This article was previously published under Q305745



SUMMARY
This article describes how to use aliasing in COM+ 1.5.



MORE INFORMATION
Aliasing is a new feature in COM+ 1.5. You can use aliasing to configure one Component Object Model (COM) component in multiple COM+ applications. In COM+ 1.0, an error occurs when you add a COM component to more than one COM+ application.

Aliasing is useful because you can configure a single COM component so that it has different properties in one or more COM+ applications. For example, in one COM+ application, you can configure the component to use transactions. In another application, you can configure the same component so that it does not use transactions.

This article assumes that you know how to create COM components for use in COM+.

How to Alias a Component Using Component Services
To alias the component by using the Component Services Microsoft Management Console (MMC), follow these steps:
 * 1) Create a simple COM component that has one method that returns a string.
 * 2) Install this test component in a COM+ application.
 * 3) From the Windows Start menu, click Settings, click Control Panel, click Administrative Tools, and then click Component Services to open the Component Services MMC.
 * 4) Create a new COM+ Server Application that will host the aliased component.
 * 5) Browse to the location in which you installed the test component.
 * 6) Right-click the component, and then click Alias.
 * 7) In the Alias Component dialog box, in the left pane, click the COM+ application that you created in step 4.
 * 8) Leave the default values for Original ProgID and New CLSID.
 * 9) Change the value of New ProgID to something different than the original ProgID.
 * 10) Click OK to create the aliased component.

How to Alias a Component Using COMAdmin APIs
To alias the component by using the COMAdmin Application Programming Interfaces (APIs), follow these steps:  Create a simple COM component that has one method that returns a string. Install this test component in a COM+ application. Create a new Microsoft Visual Basic EXE project named TestAliasing. Add a reference to the COM+ 1.0 Admin Type Library and the COM+ Services Type Library. Add a Command button to the form.  Add the following code to the command button's Click handler: Dim pCat As COMAdmin.ICOMAdminCatalog2 Set pCat = New COMAdmin.COMAdminCatalog pCat.AliasComponent &quot;SourceApplication&quot;, &quot;SourceProgID.TestObject&quot;, _ &quot;DestinationApp&quot;, &quot;DestinationProgID.TestObject&quot;, &quot;&quot; Set pCat = Nothing NOTE: The AliasComponent method takes five parameters:

 The first parameter is the source COM+ application.</li> The second parameter is the source ProgID.</li> The third parameter is the destination COM+ application.</li> The fourth parameter is the destination ProgID.</li> The fifth parameter is the CLSID.</li></ul>

In this sample, the CLSID is blank, which means that it will be generated automatically. </li> Build and run the project.</li> Click the button. Notice that the new ProgID appears in the destination COM+ application.</li> Build a test client to test the original component and the aliased component. Notice that when you call the aliased component, the destination COM+ application starts, and that component's configuration properties are used.</li></ol>

NOTE: The destination COM+ application for the aliased component can be the source COM+ application. In fact, if you use the COMAdmin APIs and leave the destination application string blank, the new component is added to the source application.

Keywords: kbhowto kbsysadmin KB305745

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.