How to Auto-Update Windows Mobile application

2019-02-02 16:48发布

问题:

I have a .net cf 3.5 Windows Mobile application that my client wants to have autoupdate features.

Here is what I have so far:

  1. create a CAB using the Smart Device CAB Project (is this good enough, or should I be doing something else here)

2.Get the application version number

Assembly.GetExecutingAssembly().GetName().Version.ToString();
  1. Call a WCF web service for to do a version number look up.
  2. Download a new version of the cab file.
  3. ???
  4. Execute WCELoad.exe on the CAB file
  5. Profit

回答1:

Your solution is generally correct, but has a few problems.

  1. You can't update yourself. You have to shut down and have some otehr app update you to prevent the file-sharing issue. This is usually handled by having a dedicated "updater" app that you launch. It might be the target of the app icon and therefore does updates with every launch, or it may be launched via a "check for updates" type of menu item. Regardless, you have to launch it and make sure the actual app isn't running.
  2. It's generally a good idea to provide some form of back-up in the event of a corrupt, interrupted install
  3. CAB updates are going to require wholesale updates of everything. This may not be what you want in the end (you may want to update just a single file, assembly or whatever) so starting with the logic of pulling down individual files is going to make you way more extensible.

An old, but still very valid, resource is Alex Feinman's MSDN article on creating self-updating applications.



回答2:

I just published WmAutoUpdate, a .NET c# framework that will do auto-updates on the Compact Framework. It's freely available on Github: http://github.com/seboslaw/wmautoupdate



回答3:

It is not necessary to create a dedicated app to update, at least not on WM 6 with .netcf 3.5. I'm downloading .cab file using a webservice and then start a new process and invoke wceload to do a silent cab install. This takes care of shutting down my running app, uninstalling it and then performs the install like stated in MSDN docs here

In Windows Mobile Version 5.0 and later, when using Wceload.exe to reinstall a .cab file, Wceload.exe uninstalls the previously installed version of the .cab file before installing the new version. During the uninstallation portion of this process, Wceload.exe closes any currently running executables that were installed on the target device using a .cab file, based on their filename. Wceload.exe also closes any executables that are the target of a file operation, such as a move or a copy. To close an executable, Wceload.exe sends WM_CLOSE to all top-level windows owned by the process. If the process does not exit in a timely manner after receiving the WM_CLOSE message, then Wceload.exe forcibly closes it by calling TerminateProcess. Wceload.exe does not attempt to close executables that are shipped in the run-time image on the target device.

I also have a cesetup.dll for additional cleanup of files during uninstall.

The big problem i have is that i cannot change the installation folder for my app when doing a silent install and it defaults to %installDir% property from my .inf file. And building a separate .cab for every device that wants to update is not a pretty solution.



回答4:

A team I was on implemented this by creating a second mobile app (outside of the application that is being updated) on the mobile devices that was responsible for downloading and running CABs.

  • On every dock, the primary app determined if it needed to be updated via a web service call.
  • If its version was out of date, it would invoke the updater app with the URI of the new version to install and then exit
  • The updater app would download the new CAB and execute the installs/reboots and registry modifications as appropriate.

This worked for us pretty well.



回答5:

You are right. after wM5, 6... WCEload just stops the aplication if it's installed, so you don't need to stop it manually. but You need to install the update in silent mode because if not the user can cancel it, so you need the silen cab installer. download it from

http://cssoft.freehosting.net/website2/default.html