How to Configure COM communications when the COM Server and COM Client components are running in different Containers

10/07/2019 Cliff Hobbs   ID: 359085

Purpose

The purpose of this article is to detail how to configure an application that uses the Component Object Model (COM) in the scenario where the COM Client and Server components are running in different Cloudhouse Containers.

Note

This article only applies to Containers created from release 1903 onwards.

See COM support in Cloudhouse Compatibility Containers for background information on COM and the scenarios currently supported by Cloudhouse Containers; and How to troubleshoot COM in Cloudhouse Compatibility Containers for details of how to troubleshoot COM.

Also, if your COM Server and COM Client components are running in the same Container, see How to enable support for out of process COM (COMVirtualization) in a Cloudhouse Container for details of how to configure this.

If your application consists of a COM client module running in a Container on one machine, that needs to communicate with a COM server module running in a Container on a different machine, then this is classed as Distributed COM (DCOM), not a COM application. In this scenario, you should follow the How to Configure DCOM for Cloudhouse Compatibility Containers article. 

Step-by-step process

There are three parts to this process:

Configuring the COM Server Container

To configure the Container containing the COM server:

Note

For this article, the Container containing the COM server is running a COM server application called TestCOMServer64.exe

  1. On the computer running the Container that contains the COM server application, navigate to the Container folder.
  2. Open the ComDeployment.xml file in a text editor, such as Notepad++.
  3. Enable COM (which is disabled by default) by changing Enabled="false" to Enabled="true"
    For example:
    <?xml version="1.0" ?> 
    <COM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Enabled = "true">
      <OutOfProcServers>
        <OutOfProcServer>
          <Path>%DefaultDir%\ProgData\Program Files\TestComServer\TestCOMServer64.exe</Path> 
        </OutOfProcServer>
      </OutOfProcServers>
    </COM>
  4. Deploy the COM Server Container using Cloudhouse.Container.Deploy.exe as detailed in Deploying Containers.

This completes configuring the COM server Container. Next, we need to configure the Container containing the COM client.

Configuring the COM Client Container

To configure the Container containing the COM client:

Note

For this article, the Container containing the COM client is running a COM client application called TestCOMClient64.exe

The first part of the process is to find out the CLSID (also known as the class ID) which is the globally unique identifier that identifies a COM class object, which in this case is the COM server application.

To do this:

  1. On the computer running the Container that contains the COM server application, navigate to the Container folder.
  2. Open the ComRegistryKeys.xml file in a text editor, such as Notepad ++.
  3. Search this file for the name of the COM server application. In our example, we need to search for TestCOMServer64.exe
    For example:
      <Write>
        <KeyName>HKEY_CURRENT_USER\Software\Cloudhouse\AppAccelerator\%GUID%\HKLM\SOFTWARE\Classes\CLSID\{67c9e120-9365-4a43-878e-c8f17d5ef51e}\LocalServer32</KeyName>
        <ValueName />
        <Value ValueType="String">%DefaultDir%\ProgData\Program Files\TestComServer\TestCOMServer64.exe</Value>
      </Write>
  4. Make a note of the value of the CLSID for the COM server application. In our example, this is:

{67c9e120-9365-4a43-878e-c8f17d5ef51e} as shown below:

  <Write>
    <KeyName>HKEY_CURRENT_USER\Software\Cloudhouse\AppAccelerator\%GUID%\HKLM\SOFTWARE\Classes\CLSID\{67c9e120-9365-4a43-878e-c8f17d5ef51e}\LocalServer32</KeyName>
    <ValueName />
    <Value ValueType="String">%DefaultDir%\ProgData\Program Files\TestComServer\TestCOMServer64.exe</Value>
  </Write>

Note

Check the remainder of the ComRegistryKeys.xml for other instances of the same COM server application, but with different CLSIDs. Make a note of any additional CLSIDs for the application.

The next part of the process is to find out the PackageID of the Container containing the COM server. To do this:

  1. On the computer running the Container that contains the COM server application, navigate to the Container folder.
  2. Open the chmetadata.json file in a text editor, such as Notepad ++.
  3. Make a note of the value specified for the PackageID entry. In our example, this is TestCOMServer_2136
    For example:
    {
      "PackageId": "TestCOMServer_2136",
      "IsTelemetryEnabled": true,
      "TelemetryApiUrl": "https://telemetry.cloudhouse.com/telemetry",
      "Icon": "%DefaultDir%\\Cloudhouse.Container.Run.exe",
      "Name": "TestCOMServer",
      "Version": "",
      "Publisher": "",
      "AuthUrl": "https://auth.cloudhouse.com/oauth/token",
      "UsageReportingUrl": "https://containers.cloudhouse.com/api/UsageEvents"
    }

Now we have the CLSID(s) and PackageID of the COM server components, we can configure the COM client with them. To do this:

  1. On the computer running the Container that contains the COM client application, navigate to the Container folder.
  2. Open the AppAcceleratorV.clc file in a text editor, such as Notepad ++.
  3. Search for the <Features> section.
  4. Verify a line for the COMVirtualization feature is present which enables this feature. If it is not, add the line and save the AppAcceleratorV.clc file.
<Features>
   <Feature>COMVirtualization</Feature>
</Features>
  1. In your text editor, search for the <COM> section of the AppAcceleratorV.clc file.
  2. Add a line for the CLSID noted earlier in the following format: 

<CLSID ID="{<cls_id_of_com_server>}" ExternalPackageId="<packageid_of_com_server>"/> 

where {<cls_id_of_com_server>} is the CLSID of the COM server component and <packageid_of_com_server> is the Package ID of the Container running the COM server.

For our example, the line will be:

<COM>
  <CLSID ID="{67C9E120-9365-4A43-878E-C8F17D5EF51E}" ExternalPackageId="TestCOMServer_2136"/>
</COM>
  1. Repeat Step 6 to add any additional CLSIDs for the COM server application.

The final part of the process is to run/deploy the COM Client Container using Cloudhouse.Container.Deploy.exe as detailed in the Deploying Containers article.

This completes configuring the COM client Container. We now need to confirm the two COM applications in their Containers can communicate with each other via COM.

Testing COM works

To test that COM works between the Containers:

  1. Verify both the server and client COM Containers have been deployed.
  2. Invoke a process on the COM client application to verify it can communicate successfully with the COM server application.
Source:
Was this article helpful?

Table of Contents

    Can't find what you're looking for?

    Contact Support