C# - Retrieve properties of a COM+ component?
Asked Answered
P

1

5

I have a COM+ component on a server (Windows Server 2003). Is there any way I can programmatically retrieve the properties of this component, (e.g. the constructor string used)?

When I go to Administritive Tools -> Component Services -> COM+ Applications and right click on my component, these are the properties I want to be able to retrieve and write to a file.

Is there any way I can do this?

Thanks in advance.

Phosphorism answered 30/6, 2010 at 19:42 Comment(0)
W
7

You can use the COM+ Administration API to retrieve the properties of a component. The various collections you can retrieve can be found here. From visual studio you would add a reference to the COM+ 1.0 Admin Type Library. Essentially you would then do something like (not tested):

COMAdminCatalogCollection applications;
COMAdminCatalog catalog;

catalog = new COMAdminCatalog();
applications = (COMAdminCatalogCollection)catalog.GetCollection("Applications");
applications.Populate();

foreach(COMAdminCatalogObject application in applications)
{
    //do something with the application
    if(  application.Name.Equals("MyAppName") )
    {
        COMAdminCatalogCollection components;
        components = applications.GetCollection("Components", application.Key)

        foreach(COMAdminCatalogObject component in components)
        {
            // do something with component
        }
    }

}
Waring answered 30/6, 2010 at 20:15 Comment(2)
That looks like exactly what I'm looking for - I'll investigate. Thanks Garett for the response.Phosphorism
"components.Populate();" is missing before looping through the collection.Limitation

© 2022 - 2024 — McMap. All rights reserved.