Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A command line tool to deploy COM components in COM+

0.00/5 (No votes)
25 Jan 2008 1  
In a mixed .NET/COM COM+ based environment, one may find a need for a command line tool to deploy COM components in COM+.

Introduction

In a mixed .NET/COM COM+ based environment, one may find a need for a command line tool to deploy COM components in COM+. Such a tool simplifies the deployment of such mixed technologies by allowing a full command line based deployment.

In the good old days of DNA, COM+ components where registered using MSIs. The latter were created using the COM+ export function or other tools like Orca, and included the component DLL(s), their dependencies (other DLLs, TLBs), and the COM+ configuration attributes for the package, components, and interfaces. A typical DNA deployment scenario included a series of MSIs representing multiple COM+ packages, and a master MSI or installation script to bind them all.

.NET [re]introduced the idea of command line deployment. Serviced Components are registered using the framework provided RegSvcs utility. In this scenario, the assembly's dependencies are expected to coexist in the same folder or GAC, and COM+ configuration attributes are annotated inline [code] using EnterpriseServices custom attributes.

The differences noted above make the deployment in a mixed .NET/COM environment challenging: While the .NET serviced components are deployed using a simple command line script, the veteran COM component deployment requires that either MSIs or a series of more complicated VBS scripts (COMAdmin based) are put together. Things become more uncomfortable when you try to utilize a modern [ANT like] deployment tool which tend to like the command line approach over the MSI one.

RegComPlus

The suggested solution in this article is a command line utility [similar to RegSvcs] which allows an easy, one line, registration of COM components in COM+. The lack of inline annotated COM+ configuration attributes in COM based languages like C++ and VB make life a bit more difficult, which is why the utility has two modes:

Basic mode: Designed for inproc (a.k.a. library) packages, using “all default” COM+ configuration.

These are registered in a similar way to how service components are registered using RegSvcs: all you need to specify is the path to the DLL and the package name, and the utility will do the rest.

Example: RegComPlus.exe %binpath%\example.dll ComPlusPackageName >> %logfile%

Advanced mode: Designed for out of process (a.k.a. server) packages, or packages that include multiple DLLs, or packages that require specific configuration of components and/or of interfaces.

Such COM+ packages require additional configuration information that is not accessible to the registration utility; this is where a configuration file comes into play. The configuration file attempts to cover all the desired COM+ attributes otherwise available via the COM+ MMC user interface or the COMAdmin library. More details on the configuration file is available below.

The advantage of using a configuration file vs. COMAdmin based VBS scripts is that the deployment stays simple and easy to maintain: The [more] complex COM+ configuration code is encapsulated in the utility, and changing the desired configuration does not require coding skills. Additionally, once the configuration file is created, the deployment becomes a one [command] liner in a similar way to how serviced components are registered using RegSvcs: all you need to specify is the path to the config file, and the utility will do the rest.

Example: RegComPlus.exe %binpath%\example.config >> %logfile%

The Config File (Advanced Mode)

The config file is XML based. It attempts to cover all the desired COM+ attributes otherwise available via the COM+ MMC user interface or the COMAdmin library. The config file supports installing multiple files in a package and the configuration of all three levels of COM+ objects hierarchy: the package, the components and the interfaces.

The following attributes are supported; do note that partial configuration is supported, and required nodes/attributes are marked as such.

Package (required):

  • name: Package name. Required.
  • isolation: Library/server. Default: library.
  • run_when_idle: true/false. Default: false.
  • queued: true/false. Default: false.
  • queue_listening: true/false. Default: false.

File (at least 1 required):

  • name: File name. Required. Note: if full path is not specified, the file is assumed to exist in the same directory as the config file.

Component (optional):

  • name: Component name. Required. Note: must match component’s ProgID.
  • transactions: 0…4. Default: 3.
    • TransactionIgnored = 0
    • TransactionNone = 1
    • TransactionSupported = 2
    • TransactionRequired = 3
    • TransactionRequiresNew = 4
  • synchronization: 0…4. Default: 2
    • SynchronizationIgnored = 0
    • SynchronizationNone = 1
    • SynchronizationSupported = 2
    • SynchronizationRequired = 3
    • SynchronizationRequiresNew = 4
  • jit: true/false. Default: true.
  • pooled: true/false. Default: true.

Interface (optional):

  • name: Interface name. Required. Note: must match interface’s ProgID.
  • queuing_enabled: true/false. Default: false.

Simple Example:

<configuration>
  <package name="ComPlusPackageName " isolation="server">
    <files>
      <file name="example.dll"/>
    </files>
  </package>
</configuration>

Moderate Example:

<configuration>
  <package name="ComPlusPackageName">
    <files>
      <file name="example.dll"/>
    </files>
    <components>
      <component name="ComPlusComponent1" synchronization="3"/>
      <component name="ComPlusComponent2" 
        transactions="1" synchronization="1" jit="false"/>
    </components>
  </package>
</configuration>

Complex Example:

<configuration>
  <package name="ComPlusPackageName" 
           isolation="server" 
           queued=”true” queue_listening=”true”>
    <files>
      <file name="example.dll"/>
      <file name="c:\mydirectory\example2.dll"/>
    </files>
    <components>
      <component name="ComPlusComponent1" synchronization="3"/>
      <component name="ComPlusComponent2" transactions="1" 
                    synchronization="1" jit="false"/>
      <component name="ComPlusComponent3" transactions="4"/>
      <component name="ComPlusComponent4">
          <interface name="ComPlusInterface4" queuing_enabled=”true”>
      </component>
    </components>
  </package>
</configuration>

Technology

The RegComPlus utility was coded in C#, and utilizes the COMAdmin library over System.Runtime.InteropServices.

Additional Reading

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here