thecornflake

Hi,

I'm using VB.NET 2003.

I need to be able to count the number of objects for a certain COM+ component within a COM+ application. When you browse in Component Services to the components in an application, if you select the details view there is an Objects column. That's the value I want to pick up.

I can find my component (and retrieve a count of the total number of components in the application - that's easy), but now I'm stuck on how to count the objects for that one component.

I've tried Googling this without much success, and also poste don vbcity and dreamincode. Someone at VBCity pointed me towards Reflection, but that doesn't seem to work.

I think I'm looking at it the wrong way - I don't think the object count is a specific property of the component.

If anyone has any ideas it would be greatly appreciated.


Re: Common Language Runtime Getting object count from component services for a component

Feng Chen - MSFT

Hi thecornflake,

To achieve the goal, you can try using COM+ instrumentation APIs:

COM+ Instrumentation Interfaces

http://msdn.microsoft.com/library/default.asp url=/library/en-us/cossdk/html/009aa503-3fcd-4046-9a74-23a1a9c23e6a.asp

Particularly the IComObjectConstruction2Events interface which notifies the subscriber if a constructed object is created can be useful.

If that's too difficult for you, you can also try the undocumented COMSVCS.TrackerServer component. Some relevant sample can be found at the following link:

http://www.egilh.com/blog/archive/2005/02/25/557.aspx

Hope they can help you!

Thanks!






Re: Common Language Runtime Getting object count from component services for a component

thecornflake

The second link looks like what I need, but it's in C++ not VB.NET and I don't know C++. I've Googled but there doesn't seem to be any easy way to convert it. I'll try and do it manually and if it works I'll post the code in case anyone else wants to do the same.




Re: Common Language Runtime Getting object count from component services for a component

thecornflake

Stupidly I hadn't scrolled down from the code example in that link. Someone has posted a full VB.NET version which works perfectly.

Thanks for all your help.