Programming the COM+ Catalog

You can access the COM+ Catalog from within any .NET managed component (not only serviced components). To write installation or configuration code (or manage COM+ events), you need to add to your project a reference to the COM+ Admin type library. After you add the reference, the Catalog interfaces and objects are part of the COMAdmin namespace. Example 10-10 shows how to create a catalog object and use it to iterate over the application collection, tracing to the Output window the names of all COM+ applications on your computer.

Example 10-10. Accessing the COM+ Catalog and tracing the COM+ application names

using COMAdmin;

ICOMAdminCatalog catalog;
ICatalogCollection applicationCollection;
ICatalogObject application;

int applicationCount;
int i;//Application index 

catalog = (ICOMAdminCatalog)new COMAdminCatalog(  );
applicationCollection = (ICatalogCollection)catalog.GetCollection("Applications");
         
//Read the information from the catalog
applicationCollection.Populate(  ); 
applicationCount = applicationCollection.Count;
 
for(i = 0;i< applicationCount;i++)
{   
   //Get the current application   
   application= (ICatalogObject)applicationCollection.get_Item(i);   
   int index = i+1;
   String traceMessage = index.ToString()+". "+application.Name.ToString(  );

   Trace.WriteLine(traceMessage);
}

Tip

The System.EnterpriseServices.Admin namespace contains the COM+ Catalog object and interface definitions. However, in the Visual Studio.NET Beta 2, the interfaces are defined as private ...

Get COM & .NET Component Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.