How To Alias a Component in COM+ 1.5 (305745)



The information in this article 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:
  1. Create a simple COM component that has one method that returns a string.
  2. Install this test component in a COM+ application.
  3. Create a new Microsoft Visual Basic EXE project named TestAliasing.
  4. Add a reference to the COM+ 1.0 Admin Type Library and the COM+ Services Type Library.
  5. Add a Command button to the form.
  6. Add the following code to the command button's Click handler:
          Dim pCat As COMAdmin.ICOMAdminCatalog2
          Set pCat = New COMAdmin.COMAdminCatalog
          pCat.AliasComponent "SourceApplication", "SourceProgID.TestObject", _
                              "DestinationApp", "DestinationProgID.TestObject", ""
          Set pCat = Nothing
    						
    NOTE: The AliasComponent method takes five parameters:

    • The first parameter is the source COM+ application.
    • The second parameter is the source ProgID.
    • The third parameter is the destination COM+ application.
    • The fourth parameter is the destination ProgID.
    • The fifth parameter is the CLSID.

    In this sample, the CLSID is blank, which means that it will be generated automatically.
  7. Build and run the project.
  8. Click the button. Notice that the new ProgID appears in the destination COM+ application.
  9. 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.
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.

Modification Type:MinorLast Reviewed:6/29/2004
Keywords:kbhowto kbSysAdmin KB305745