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.RegistrationHelperclass. 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
- 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
TypeLibConverterclass in the
- All Custom attributes implemented in
System.EnterpriseServicesfor COM+ registration have private implementations of the
System.EnterpriseServices.IConfigurationAttributeinterface. All the basic catalog registration is driven through this interface. In essence, a great deal of the work of the
RegistrationDriveris simply to iterate through collections of types to extract this attributes and call the
IConfigurationAttributemethods on them at the appropriate time.
- The interface has the following declaration:
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
IConfigurationAttributeinterface take a Hashtable as an argument,
in which keys are strings, and values are instances of types that implement the
ICatalogObjectinterface. As you've probably guessed by now, common keys in
the Hashtable are the three strings presented above ("Application", "Component", "Method").
Apply()method is where most of the work actually occurs. Most attribute classes simply
get the appropriate
ICatalogObjectinstance out of the Hashtable and call
to configure a particular property in the COM+ Catalog, so it's actually quite straightforward.
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...