1

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?

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
mraviator
  • 4,034
  • 9
  • 38
  • 51
  • 2
    Can you show the code where you hook up to InstallStateChanged? Especially *when* you do it? – Austin Lamb Feb 11 '11 at 23:07
  • There's really nothing to show. On my install page, I execute Application.Current.Install in the code behind. Then in the App code behind, I have an InstallStateChange event with code in it. When you refer to "hook up", are you suggesting I need to explicitly set a new event handler for InstallStateChanged to work? I'm doing this in VB. – mraviator Feb 12 '11 at 11:21

1 Answers1

0

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
mraviator
  • 4,034
  • 9
  • 38
  • 51