Just out of curiosity, I decided to sniff around and see how Regscvs.exe does it's work to register an assembly in a COM+ application. While this information is probably not very useful to anyone, I'm posting here a few interesting snippets of what I found:

  • Regsvcs is just a driver around the System.EnterpriseServices.RegistrationHelper class. This class is esentially a wrapper that ensures that all registration is done from a thread in an appropriate apartment, while the actual registration work is done inside the RegistrationDriver class (the entry point to this class is the InstallAssembly() method).
  • First thing It does is create a TLB if it's needed, which is done through the RegistrationDriver::GenerateTypeLibrary() method, which is, of course, done through the TypeLibConverter class in the System.Runtime.InteropServices namespace.
  • All Custom attributes implemented in System.EnterpriseServices for COM+ registration have private implementations of the System.EnterpriseServices.IConfigurationAttribute interface. All the basic catalog registration is driven through this interface. In essence, a great deal of the work of the RegistrationDriver is simply to iterate through collections of types to extract this attributes and call the IConfigurationAttribute methods on them at the appropriate time.
  • The interface has the following declaration:

    interface IConfigurationAttribute
    {
    bool IsValidTarget(string s);
    bool Apply(Hashtable info);
    bool AfterSaveChanges(Hashtable info);
    }

  • The first method called is IsValidTarget(), which should return true if the registration
    attribute can deal with the specified kind of object, which is identified in COM+ terms with a string.
    So for example, here are some possible values:

    • "Application": The object representing the COM+ application object being created.
    • "Component": The object representing the COM+ component being registered.
    • "Method": The method of the component/interface being processed.


  • Both of the other two methods of IConfigurationAttribute interface take a Hashtable as an argument,
    in which keys are strings, and values are instances of types that implement the
    ICatalogObject interface. As you've probably guessed by now, common keys in
    the Hashtable are the three strings presented above ("Application", "Component", "Method").
  • The Apply() method is where most of the work actually occurs. Most attribute classes simply
    get the appropriate ICatalogObject instance out of the Hashtable and call SetValue() on it
    to configure a particular property in the COM+ Catalog, so it's actually quite straightforward.
  • The AfterSaveChanges() method is, from what I can tell, basically a way to
    provide for two-step registrations. Most attibutes simply don't do anything in this method (In fact, I couldn't find any
    attribute that actually takes advantage of this method in v1.0 of the framework.).

Keep in mind, of course, that all of this stuff is completely undocumented, and very likely to change in future
versions of the framework...



Tomas Restrepo

Software developer located in Colombia.