次の方法で共有


Deploying applications to Windows Mobile

I thought I would be a little different and make my first post as useful as possible by including some of my latest work. I guess I cant totally skip the intro bit tho: My name is Marcus Perryman and I've been working with or for Microsoft in the UK for the last 8 years in various technical roles including C++ product support, internal systems development, application development consultancy for the last 5 years and in the Developer & Platform Community team for the last 5 days! Code is my passion and my way of life. My first love is C/C++ and I often find myself still reverting to it although C# is fast becoming my new love. I have never really got on well with VB and it still scares the hell out of me when presented with a page of complex VB code ... total respect for anyone that can!

I guess I will always have a passion for small, shiny toys that can run my code and for 4 years now I have focused on Windows Mobile Pocket PC's and Smartphones. My bag is rarely found with less than 4 mobile devices and I have a relatively full museum of devices for those devices I don’t carry on a particular day (more another day maybe). I can still clearly remember the day Mike Hall brought his AutoPC (remember that device?) into the office and 30 mins later we had 'hello world' up and running... there was no looking back!

So what are you likely to see on my Blog? I guess it’s inevitably going to be mainly mobile stuff to start with but I am hoping to try something new over the next 6 months and I'm digging into ASP.NET 2.0 to see what all those web developers get so excited about. Lets see how things progress.

Anyway, onto the useful stuff. I contribute to the UK MSDN Flash news letter that is sent out every couple of weeks and have just done a piece on deployment to mobile devices. There is a lot in there for Windows Mobile to cover pretty much every eventuality but I find that most developers are usually only aware of some options. MSDN flash articles are tightly restricted in length so I've just covered the basics.

"Deploying Mobile Device Applications

Mobile applications require many of the same engineering considerations as other development paradigms but some areas such as deployment bring their own, unique challenges due to the very mobile nature of devices. During development of managed and native applications both Visual Studio .NET 2003 and Embedded Visual C++ deal with deployment to a device over Active Sync very adequately but much more is needed to distribute and manage final product deployment.

 

First of all let’s consider the basic components needed to deal with deployment to Windows Mobile powered devices:

 

Cabinet Files

The first step to deployment involves packaging all the required components and configuration information into a simple manageable form. Windows Mobile provides support for the Cabinet (CAB) file technology which is the predecessor to MSI on the desktop. CAB’s are a concatenation of files, configuration information and an install script that define the destination for files, list registry key changes, create shortcuts to your applications and even allow you to run code during the install. Installation with a CAB file has the added benefit of automatically creating an uninstall option based on the CAB install script and deploying via a CAB file is required to achieving Windows Mobile logo certification.

 

Creating CAB Files

Three things are required to create a CAB file: your deployment components; a .INF file that describes how to build those components into a CAB file; and the ‘cabwiz’ utility that ships with many different products including Visual Studio .NET 2003 and Embedded Visual C++.

 

Visual Studio .NET provides a neat facility to assist in creating CAB files: select the menu Build | Build CAB File and Visual Studio .NET 2003 will create an INF file for all the components of the selected project including multiple processor targets, and it even creates a batch file for you. This is a great starting point for you to extend to include other components of your application. For a full description of CAB file capabilities click here.

 

Getting the CAB File to your Device

ActiveSync includes a facility called Application Manager that provides a transparent mechanism to install and remove applications from a connected device and is an ideal solution for deploying ISV applications such as games and utilities. To use Application Manager you must provide a simple INI file that describes your application including the CAB files that need to be installed, and then call CEAppMgr.exe with the name and location of your INI file. This step would normally take place as the last step of a desktop installer such as an MSI package. For more information about Application Manager click here.

 

For the Enterprise Connected Device?

Enterprise situations are somewhat different as devices are less likely to have an ActiveSync partnership. In this case CAB files can be deployed via e-mail attachments or as intranet downloads. Ideally the process should be a little more complete and include remote management of the device. Today there are a number of solutions in the marketplace for device management including Microsoft SMS 2003 with the advent of the Device Management Feature Pack. This free add-on to SMS 2003 SP1 provides all the basic management features such as hardware and software inventory, password policy and device settings management as well as being able to deploy your shiny new CAB file over the air. For more information about SMS 2003 Device Management Feature Pack click here for the download page or here for an on-demand web cast of the main product features.

 

Disconnected Devices?

For disconnected devices removable media might be the only option to deploy applications. In this case we can make use of a feature of Windows CE that detects when a storage card is inserted or removed from the device and if present, a processor specific version of Autorun.exe is copied to the windows directory and automatically run. This provides the ideal mechanism to automatically start the installation of cab files placed on the card. For more information about Autorun click here.

 

Summary

Remember, the first step is to build your CAB file. Make this part of the daily build right from the start of your project and you will see the benefits throughout the development cycle. Choosing a deployment technique requires knowledge of your target device, but every scenario is catered for.

 

Bye for now"

 

Let me know if there is anything in Windows Mobile (or ASP.NET 2.0) you have a specific interest in and I will endeavour to share what I know.

Marcus

Comments

  • Anonymous
    January 10, 2005
    Hi Marcus,

    A great topic to pick for your first post - I think that deployment is one of the most frustrating areas in mobile software development. I would love to see a fully managed set of API's in the future to cover the deployment process including uninstallation.

    In fact that is one topic you might be able to shed some light on - the documentation I've found so far for creating a device specific setup.dll to uninstall your software is fairly sketchy!

    An example with some common tasks (ending your application process, removing files, cleaning reg keys etc) would really help people struggling to put the polishing touches to their mobile applications, certainly as this is all unmanaged C code and possibly a hurdle to new developers starting out mobile application development using .NET Compact Framework.

    I'm working on a project at TVP/MTC in a few weeks and your name was mentioned in connection with it - hopefully we'll get a chance to chat about some of the above.

    I look forward to some really good Windows Mobile focused posts - good luck with your blog, Subscribed!

    J

  • Anonymous
    January 11, 2005
    I've got a specific interest in Windows Mobile development and XML. Any ideas when we'll have an XMLSerializer in the .NET CF?

    I'm looking forward to your future posts.

    Regards,

    Derek.

  • Anonymous
    January 14, 2005
    James, thanks for the comments. I will dig into the deployment stuff in more detail in another post.

    Marcus

  • Anonymous
    January 14, 2005
    Derek,
    I'm pretty sure we have generic serialization planned for CF 2.0, but there also might be something in the OpenNetCF namespaces. Let me double check both of these and post about it later.

    Marcus

  • Anonymous
    June 16, 2005
    My first post on this blog was about deploying application and I touched briefly on autorun.exe. I have...

  • Anonymous
    July 21, 2005
    Is there anyway of viewing a wince cab file on windows, the best I can do is extracting the files using the fdi lib, but the names are mangled and all the info in the .inf file seems to be lost. Any idea if there is a specification for the cab file once it has been through cabwiz?

  • Anonymous
    August 19, 2006
    The comment has been removed

  • Anonymous
    August 19, 2006
    The comment has been removed

  • Anonymous
    November 27, 2006
    The comment has been removed

  • Anonymous
    June 09, 2007
    Marcus, I wish you'd comment on all of the considerations involved in constructing a silent updater, i.e. absolutely zero modal dialogs posted by wceload - which registry keys need to be reset, deleted, or whatever. Thanks, Mike

  • Anonymous
    September 11, 2007
    Marcus, I've just ventured into Mobile Applications development. I found the blog very useful. Congrants and Thanks.

  • Anonymous
    July 26, 2008
    I wish that you could elaborate in detail about how to uninstall (or "repair" or "update") an application which was installed previously. Or send me some links about that: cdang_2000@yahoo.com Thank much, Marcus

  • Anonymous
    August 05, 2008
    Hi, I need a help. I just want to ask one question about if i want to make one client server application whose client is mobile device and server is my pc and i want to provide one form which accepts certian input from mobile device and save it on my server(my Pc). Now i can make it by either using "mobile web application" or using winform application. If i make web application then i dont have to do anything at mobile device as long as it has browser, m i right? But if mobile doesnt have browser and if i have to make winform application then what would be the best way to do that? What i thought is:

  1. make one webservice
  2. make winform application which calls this servie to communicate with database server.
  3. deploye this application on mobile. Does it make any sense? Your comments and suggestions will be highly appriciated. Thanks --Anand
  • Anonymous
    September 15, 2008
    Hi Marcus, Could you help me with this: My app needs to access a settings.xml file on a folder 'conf' so I created this folder in the Application Folder and put there my settings.xml file then I built the CAB file. When I install the CAB, it creates the folder and the file as said .. but when I unistall my app it does not remove the folder and file .. How can I say to my CAB that I would like to remove the folder and file it created!? And my second question is .. Is there a way to say to CAB that this folder or that file should be a hidden one? Thnks Fábio Pupo fooues@gmail.com

  • Anonymous
    December 30, 2011
    how to remove deployed application on phone device? cause my phone keep restart because of the deployed application.