Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed



email article
printer friendly
get the code

Update CF Apps Automatically
Simplify the administration and updating of Compact Framework applications by writing a Web service that facilitates checking for new files for a given app, as well as downloading and updating that app if a newer version exists.
by John Gavilan

November 30, 2006

Technology Toolbox: C#, XML, Microsoft Compact Framework

Recent advancements in mobile devices and software development have opened up new possibilities that can increase productivity for mobile workers significantly.

ADVERTISEMENT

Applications as trivial as e-mail and address books are already commonplace for Pocket PCs and Smart Phones. More advanced applications—including work order fulfillment reporting, photo capture, employee time tracking, expense reporting, and even GPS enabled apps—are now possible and developed easily using the .NET Compact Framework.

However, most of these apps face a crucial limitation that could hinder more widespread deployment of these types of enterprise applications: the ability to download updates to remote devices automatically whenever new versions of the application become available.

The most common way to update custom Pocket PC applications is to connect your device to a PC physically, uninstall the application using Active Sync, and then reinstall the application using the supplied MSI that loads the updated application to your Pocket PC or Smart Phone. Another way to perform an update is to navigate to the Pocket PC's file system using Active Sync, and then copying the updated binaries from your desktop to the Pocket PC's folders. The downside: This approach isn't practical across an enterprise or even a moderately-sized deployment base. Asking non-computer savvy users to do this would mean spending lots of time on helpdesk lines walking users through this potentially problematic process—and with few guarantees users would do exactly as they were told. After all, you are the expert on the installation process, not the users.

Fortunately, there is a better way. You can build your CF-based applications so they handle the process of updating themselves automatically. I'll walk you through how to do this, explaining how to create a Web service that your mobile app can connect to that checks whether new updates exist. I'll also explain how to develop your mobile app so that it checks this Web service for updates, downloads the latest version, and then executes the main application immediately after it downloads the updates (see Figure 1). I'll also point out potential 'gotchas' along the way, including possible glitches related to establishing a TCP/IP network connection.

The solution I describe in this article requires three major pieces: the Updater Web Service, the Compact Framework Updater application, and the main application itself. The Updater Web Service serves as the repository for the main application's latest binary files. You install the Compact Framework Updater application on each Pocket PC that you deploy your application to. The main application—the CF-based application that provides the specific functionality your users need—is installed by the updater application automatically. Note that your main application must be aware of the updater application before it can initiate any updates.

You can prompt an update in a couple of different ways. First, you can invoke the check for updates every time the main application starts, that will throw up a dialog if a new version of the application exists. Or, you can prompt the user to check for updates manually. Either approach will suffice in most circumstances, but it's more likely that users will have the correct version of a given app if you perform the check every time they launch your application.

I won't just describe the concepts required for implementing such a solution, I'll also provide the code you need to implement such a solution in your own applications. The CF-based main app that this article relies on is a relatively simple "Hello World" app, but the concepts are the same, regardless of a given Compact Framework app's complexity. The real work happens in the Web service and in the polling, downloading, and installation code you place in the main app—code that is easily reusable. Note that the code online includes the source code for both the Web service and the updater application, so you can modify the code to fit your specific situation and needs.

Create the Updater Web Service
The Updater Web Service is a .NET 2.0 Framework Web Service application that resides on a public Web server. This Web server exposes two public methods: GetFileInventory and GetBinaries.

When the GetFileInventory method is invoked, the Web service reads an internal XML configuration file. This file contains information on the main mobile application's file structure. The XML file includes an element for each of the binaries required by the main mobile app. These elements contain actual file paths pointing to the network location of the binaries, a special action attribute, and the location of each of the binary files you want to install on the mobile device:

<root>
<file name=
   "C:\Projects\PPCUpdater2.0\HelloWorld\
   bin\Debug\HelloWorld.exe" action="current" 
   destination="\Program 
   Files\HelloWorld\HelloWorld.exe" />
</root>



Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
| | Discussions | Newsletters | FTPOnline Home