Home About Me Follow Me on Twitter @mikefrancis Subscribe WP7 Resources WM Resources
# Friday, April 30, 2010

Update: I've updated the sample to be independent of the '\Program Files' string. Also, the sample now supports installing onto a Storage Card.

A popular sample for demonstrating how to install application dependencies via embedded CAB files is MultiCAB Install. With this pattern you can distribute dependant cab files via a single container CAB. “Can apps be distributed via Windows Marketplace for Mobile using this?”,you ask. Yes they can.

Installing SQL Server Compact dependencies is a good fit for this pattern. I have updated the sample here customized to distribute the latest SQL Server Compact for Windows Mobile devices.

The sample checks if SQL Server Compact 3.5 is installed (See IsSQLCEUpdateRequired() in mcsetup.cpp) and if not, launches the multicab EXE which installs each dependant cab in sequence. (See the multicab whitepaper included in the sample for an in-depth explanation of how it works.)

How does the sample check to see if v3.5 is installed? It checks the registry for the following entry:

  1. \Software\Microsoft\Microsoft SQL Server Compact Edition\v3.5

This this exists, then installation of the SQLCE cabs is skipped. Note that this registry key only exists if SQLCE has been installed via a CAB file. That is, this registry key does not exist of SQLCE is in ROM. As of this writing, 3.5 (SP1 or SP2) is not distributed in ROM. See here for a list of OS and corresponding SQLCE versions: Description of the various build versions of SQL Server Compact Edition.

The sample does not do version checking on the binaries. Therefore it does not detect if you are upgrading from SQLCE 3.5 SP1 to SP2. The way it is written now, it will not update the binaries to SP2. This sample does address the popular scenario of updating an ‘off the shelf’ device with the latest version of SQL Server Compact.

More SQL Server Compact Links: Mike

This work is licensed under a Creative Commons license.
Tuesday, May 04, 2010 1:14:43 AM UTC
Hi Mike,

I tried your sample, but I had problems running on a Brazilian Portuguese Windows Mobile 6.5 device. I got a message like this "The file multicab cannot be opened. Either it is not signed with a trusted certificate or one of its components cannot be found".

I think the problem is with the hard coded path for the install dir on mcsetup.cpp:

const TCHAR c_szInstallBaseDir[] = TEXT("\\Program Files");

In Brazilian Portuguese devices, the base dir is "\\Arquivos de Programas". But is not a option to hard code this path, because we need that our app works also in English devices.

Could you help me to adjust mcsetup.cpp in order to turn it generic?

Thanks,
Matheus
Matheus
Tuesday, May 04, 2010 3:23:11 AM UTC
Matheus-
To get the localized version of "\Program Files" use SHGetSpecialFolderPath with CSIDL_PROGRAM_FILES.
Mike
Tuesday, May 04, 2010 3:48:50 AM UTC
Willthis work on Windows Phone 7?
Inkog
Tuesday, May 04, 2010 3:07:38 PM UTC
No, this will not work with Windows Phone 7. Windows Phone 7 does not use CAB files and the SQL CE run times are not compatible with Windows Phone 7.

For more information on Windows Phone 7 see: http://developer.windowsphone.com/

Thanks,
Mike
Wednesday, June 30, 2010 8:05:19 PM UTC
Matheus-
I've updated the sample to be independent of the '\Program Files' string. Also, the sample now supports installing onto a Storage Card. You can download the sample from http://blog.mjfnet.com/files/multicabinstall.zip.

Thanks,
Mike
Comments are closed.