Silverlight InstallStateChanged does not fire

320 views Asked by At

I'm developing an out-of-browser (OOB) app using Silverlight 4. For installation, I present a webpage with an install button to install the app OOB. When the user clicks the button, Application.Current.Install is executed, installing the app asynchronously.

Problem is, after the install process is complete, the InstallStateChanged event should fire, where I have code which copies data from my XAP file to the Isolated Storage. But the InstallStateChanged never fires, even though the main page displays properly upon installation.

I've tried this in Elevated Trust setting as well, no luck.

Any thoughts on this?

1

There are 1 answers

0
mraviator On BEST ANSWER

I finally figured out what I was doing wrong. I blame the lack of VB examples on the web for this :-)

In the Install_click event (executed by a user click event on the install button), I was failing to wire up the InstallStateChanged event, like so:

AddHandler Application.Current.InstallStateChanged, AddressOf App_InstallStateChanged

I failed to realize this step was needed and assumed the event fired on its own. Now I could proceed to put my post-install action code in the *App_InstallStateChanged* event routine:

Private Sub App_InstallStateChanged(ByVal sender As Object, ByVal e As EventArgs)
  'Post-install execution code here
   Select Case Application.Current.InstallState
        Case InstallState.Installed
            DisplayInstalled() 'Routine that executes upon successful install
        Case InstallState.InstallFailed
            DisplayFailed()    'Routine that executes upon failed install
   End Select
End Sub