This project is read-only.

Self updating application - The Activation never completes

Oct 12, 2007 at 12:00 PM

I am trying to implement a self updating mobile application. I am able to check for updates, download and install them. The problem is that the application never understands that the CAB executed. Actually, the myManagerActivationCompleted event is never fired in my program. The last event that I get is the myManagerActivationStarted (where I just "return true").

The result? The application gets updated, works perfectly, but when I check for new updates, it always returns that there are pending updates.

Any suggestion would be greatly appreciated.
Kyriakos Lakkas
Athens, Greece
Oct 12, 2007 at 12:29 PM
Some more info, after further debugging: The problem lies at the fact that the application gets terminated by the CAB Setup process. So, the program terminates before having the opportunity to "complete" the activation.

What am I doing wrong? Is it a problem with the CAB itself, or should I do something different in my program?
Nov 20, 2007 at 10:18 PM
I am running into the same problem, did you ever find a solution to this problem?
Nov 26, 2007 at 1:54 PM
Dear Shaunr,

I never actually found a solution, but I did manage a work around.

What I did was to make my application aware of the ManifestId that actually refers to it.

So, assume the scenario:
1. An application starts with the initial Manifest 11111111...
2. It searches for updates, finds one (Manifest 3333...), downloads and installs succesfully.
3. When the new version of the application restarts, it finds out that it has pending updates.
4. In the PendingUpdatesDetected event, it cheks the manifest of the update, towards its existing (hardcoded) ManifestID.
5. If it understands that the update refers to itself, it actually "tricks" the update engine to think that it sucessfully applied the update.

Not very clean, but it works. If anyone has a real solution for this problem, please post it.

Here is the code:

Dim CurrentManifest As String = "33333333-3333-3333-3333-333333333333"

Private Sub myManager_PendingUpdatesDetected(ByVal sender As Object, ByVal e As Microsoft.ApplicationBlocks.Mobile.Updater.PendingUpdatesDetectedEventArgs) Handles myManager.PendingUpdatesDetected

'If the pending manifest corresponds to the current one, this means that the update was successful.
If e.Manifests(0).ManifestId.ToString = CurrentManifest Then
'The update refers to "myself".
Dim path As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
path = path & "\Applications\" & e.Manifests(0).Application.ApplicationId
path &= "\" & e.Manifests(0).ManifestId.ToString & ".appliedmanifest"
Dim Srt As System.IO.Stream = New System.IO.FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read)
CType(sender, ApplicationUpdaterManager).ResumePendingUpdates()
End If
End Sub