Registering the DLL Server for Surrogate Activation

A DLL server will be loaded into a surrogate process under the following conditions:

  1. There must be an AppID value specified under the CLSID key in the registry, and a corresponding AppID key.
  2. In an activation call, the CLSCTX_LOCAL_SERVER bit is set, and the CLSID key does not specify LocalServer32, LocalServer, or LocalService.
  3. The CLSID key contains the InProcServer32 subkey.
  4. The proxy/stub DLL specified in the InProcServer32 key exists.
  5. The DllSurrogate value exists under the AppID key.

If there is a LocalServer or LocalServer32 or LocalService, indicating the existence of an EXE, the EXE server or service will always be launched in preference to loading a DLL server into a surrogate process..

The DllSurrogate named-value must be specified for surrogate activation to occur. Activation refers to calls to any of the activation functions: Activation refers to a call to CoGetClassObject, CoCreateInstanceEx, CoGetInstanceFromFile, CoGetInstanceFromIStorage, or IMoniker::BindToObject. To launch an instance of the system-supplied surrogate, set the value of DllSurrogate either to an empty string or to NULL. To specify the launch of a custom surrogate, set the value to the path of the surrogate.

If both RemoteServerName and DllSurrogate are specified for the same AppID, the RemoteServerName value is ignored, and the DllSurrogate named value causes an activation on the local machine. For remote surrogate activation, specify RemoteServerName but not DllSurrogate on the client, and specify DllSurrogate on the server.

A DLL server which is designed to always run alone in its own surrogate process is best configured with an AppID equal its CLSID. Under the AppID, simply specify a DllSurrogate named value with an empty string value.

It is best to configure a DLL server that is designed to run alone in its own surrogate process and to service multiple clients across a network with a RunAs value specified under the AppID registry key. Whether the RunAs specifies "Interactive User" or a specific user identity depends upon UI, security, and other server requirements. Specifying a RunAs value ensures that only one instance of the server is loaded to service all of the clients, regardless of the identity of the client. On the other hand, do not configure the server with RunAs If the intention is to have one instance of the DLL server running in surrogate to service each remote client identity.