COM Server Configuration

Web Connection servers can run as EXE based, out of process COM servers. COM servers are more flexible than file servers as the Web Connection .NET or ISAPI connectors can tell what instances are loaded and can detect errors and crashes and automatically launch, load and reload servers. For production installations we highly recommend you run using COM servers.

COM Server Registration

When you work in the FoxPro development environment your COM server is automatically registered when you compile your Project. The FoxPro IDE automatically creates the COM registration. Note that Admin rights are required in order to compile your server because COM registration requires that values are written to the global registry keys at HKLM.

On a deployed server, the easiest way to register your COM server is as part of your application's Configuration script which includes COM server registration.

From the FoxPro IDE (assuming your EXE exists and you're running as Admin):

do yourProject_serverconfig.prg

or running your deployed EXE:

yourProject.exe CONFIG

Make sure you have checked and tested this setup before running it on a production server.

Manual COM Configuration

If you go through the steps manually for the first installation you need to:

  • Compile the project into an EXE
  • Copy the EXE to the server (could be part of an install)
  • Register the COM object (myapp.exe /regserver)
  • Optionally Configure the COM object for DCOM permissions

Compile your Project

The first step to build a COM server is to compile your project into an EXE:

BUILD EXE yourProject from yourProject RECOMPILE

or you can also use the build script which does the same but potentially can also publish your server:

do bld_yourProject

Make sure the EXE works in file based operation by running the EXE standalone by double clicking it from Windows Explorer.

Register your Server

Once you've created your EXE file either locally or on your remote server you can use the following to register your COM Server from an Administrative Command Prompt:

yourProject.exe /regserver

Note that you have to run as Administrator as COM registration writes to the Local Machine Registry hive.

The name of the default COM server will be:

<projectName>.<projectName>Server

So if the project is called WebDemo:

WebDemo.WebDemoServer

Testing your COM Server

If the server is properly registered you should be able to test it easily either in FoxPro or using a simple VBScript script you can run from Windows.

If you have the FoxPro IDE installed try the following from your FoxPro Command Window:

loServer=CREATEOBJECT("yourProject.YourProjectServer")
? loServer.ProcessHit("query_string=wwMaint~FastHit")

If you don't have the FoxPro IDE installed on the machine you can create test using Powershell which should print some HTML to the Console:

# instantiate the server
$server =  new-object -comObject 'yourProject.yourProjectServer'

# prints an error HTML response to the console (ie. it works!)
$server.ProcessHit("")

# or point at a valid physical page url
# $server.ProcessHit("&PHYSICAL_PATH=c:\webconnection\web\wconnect\TestPage.wwd")

# release the server (optional)
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($server) | Out-Null

Enabling COM Operation on your Web Site

Once the COM server is configurated you need to enable loading of the COM server. You do this via the server configuration in web.config for .NET or wc.ini for ISAPI.

.NET Handler (web.config)

The .NET handler configures COM as part of the web.config settings in the webConnectionConfiguration> section:

<webConnectionConfiguration>
    <add key="MessagingMechanism" value="Com" />
    <add key="ComServerProgId" value="wcDemo.wcDemoServer" />
    <add key="ServerCount" value="2" />
    <add key="ComServerLoadingMode" value="LoadBased" />
</webConnectionConfiguration>

Most importantly make sure the MessagingMechanism is set to Com which enables COM operation. This value can also be toggled from the .NET Handler Status page.

Specify the ComServerProgId and ServerCount to indicate which server to load and how many instances to fire up (up 16). The ComServerLoadingMode determines how servers are loaded up either in LoadBased which loads servers based on the first COM server available or RoundRobin which always rotates servers through the entire list of servers.

ISAPI Module (wc.ini)

The ISAPI Module configures COM servers through the wc.ini file in the [AutomationServers] section:

[Main]
Mechanism=Automation

[Automation Servers]
;*** Severloading - 0 - First available   1 - Forced Round Robin
ServerLoading=1

Server1=wcDemo.wcDemoServer
Server2=wcDemo.wcDemoServer
;Server3=wcDemo.wcDemoServer
;Server4=wcDemo.wcDemoServer

Like the web.config settings first need to set the Mechanism in the [Main] section to Automation.

Then you specify the server to load by using Server1,Server2 and so to provide the ProgId. In the sample above 2 servers are loaded. You can load up to 16 servers this way.

The ServerLoading flag determines how the servers are loaded up with by the first available server, or by round robin mode which rotates through all the servers.

See also

Step 4 - Configure COM settings

© West Wind Technologies, 1996-2018 • Updated: 08/15/18
Comment or report problem with topic