How to Configure COM Server to communicate with a COM Client in a different Container

14/09/2018 Stuart Moore

Applications that require client and server COM components to run in different Containers on the same desktop or server require the <Feature>COMVirtualization</Feature> to be enabled itional configuration in the Client's Container.

Step by Step

Enable <Feature>COMVirtualization</Feature> in both of the Containers. In the following examples the ServerContainer is the application container running the COM Server, and the ClientContainer is the application container running the COM Client. The additional configuration needs to be added to the ClientContainer, in order for it to communicate with the COM Server. The COM Server container must be run first, in order to register the Server's Virtual ID (VID) and identify the CLSID (use the AAV logs) that is required in the ClientContainer's configuration.  

The Server's Virtual ID needs to be registered, so that when the app uses APIs associated with the CLSID, for example 388C7181-50E7-4959-BB46-CE8C75D9B90B, then AAV will redirect the CLSID to the virtual one.

With PackageID Example

Modify the ClientContainer's configuration to If the PackageID is specified in the AAV element, when the app starts using COM related APIs associated with the specified CLSID, for example 388C7181-50E7-4959-BB46-CE8C75D9B90B, AAV will change the CLSID to a virtual one generated using the external package id so that it is unique. 

<AAV PackageId="ClientContainer">
 <COM>
    <CLSID ID="{388C7181-50E7-4959-BB46-CE8C75D9B90B}" ExternalPackageId="ServerContainer" />
 </COM>
</AAV>

No PackageID Example

If the PackageID is not specified, then the feature will generate a VID, however there is no guarantee it will be a unique id.

<AAV>
 <COM>
  <CLSID ID="{388C7181-50E7-4959-BB46-CE8C75D9B90B}" ExternalPackageId="ServerContainer" />
 </COM>
</AAV>

Excluding a CLSID from COMVirtualization

If the CLSID element includes the parameter Excluded="True", then COMVirtualization will not virtualize this CLSID.

<COM>
  <CLSID ID="{388C7181-50E7-4959-BB46-CE8C75D9B90B}" ExternalPackageId="ServerContainer" Excluded="True" />
</COM>

Registering COM Server for Single Use

The COM Server's connection can be restricted to accepting only a single client connection with the parament ConnectionType="SingleUse".

<AAV PackageId="ServerContainer">
 <COM>
  <CLSID ID="{388C7181-50E7-4959-BB46-CE8C75D9B90B}" ExternalPackageId="ClientContainer" />
    <Registration ConnectionType="SingleUse" />
  </CLSID>
 </COM>
</AAV>


Common Errors

If COMVIrtualization is enabled, and AAV includes the CLSID and the ExternalPackageID, then AAV will log an error if the Server is not started - this is because the VIrtualID has  not been registered for the ServerContainer, and the Client cannot find it when it attempts to connect.

<AAV PackageId="ClientContainer">
 <COM>
  <CLSID ID="{388C7181-50E7-4959-BB46-CE8C75D9B90B}" ExternalPackageId="ServerContainer" />
 </COM>
</AAV>


Was this article helpful?

Table of Contents

    Can't find what you're looking for?

    Contact Support