Remote access to mobile databases
Home | Products | Buy | Support | Downloads | Contacts | Forum | Blog Search

open all | close all

Using the Pipe to install RemSqlCe.dll

Before being able to remotely access a mobile database, you have to install the appropriate version of the RemSqlCe.dll file on the target device. The install process can be made either manually by copying the file through the ActiveSync browser, through a setup process using the provided cab file or it can be automatically installed on the target device when using RAPI (ActiveSync).

To see how this can be done, we must understand how a RAPI connection is established with a cradled device and how the code takes advantage of it. When your application opens a SqlCeConnection object with the default ActiveSync connectivity, the library code actually calls Pipe.OpenRAPI or Pipe.TryOpenRAPI. The low-level sequence of events is as follows:

  1. RAPI initialization. The desktop RAPI client code is initialized and a handle is obtained to talk to the server device. If this phase fails, your code receives an error (-3 / PIPE_RAPI_INIT / PipeStatus.RapiInitFailed).
  2. OS version info collection. The target CE operating system version is queried and stored in a local varible and can be accessed through the Pipe.CeOsVersionInfo property.
  3. Device component installation. To enable this phase you need to set the Pipe.EnableInstall property to true. If the device's \Windows\RemSqlCe.dll file is not found it is copied from the desktop path set at the Pipe.DllPath property. If the device file is there, the version number of the existing file is compared to the desktop code's assumed version number. Finally, if the version numbers differ the device file is copied from the desktop to the device's \Windows directory.
  4. RAPI invocation. The desktop code invokes via RAPI an entry point in the device DLL. If this step succeeds, you have an open Pipe. Congratulations!

So, if you want to have your Pipe object automatically install the required device component, you just need to set the Pipe.EnableInstall and Pipe.DllPath properties with the correct values.

Ok, but what if I am using a SqlCeConnection class, how do I set these properties? As a matter of fact, the SqlCeConnection class does expose a Pipe property. This internal object is always created in the SqlCeConnection's constructor and can be manipulated as a standalone one through that property. The properties we discussed are only relevant when the SqlCeConnection.Open method is called, so they can be set anytime after construction and before opening the connection.