Explicitly installing an out-of-browser application in Silverlight

Below is the complete process for explicitly installing an out-of-browser application in Silverlight.

private void cmdInstall_Click(object sender, RoutedEventArgs e) 
{ 
    // Make sure that the application is not already installed. 
    if (Application.Current.InstallState ! = InstallState. Installed) 
    { 
        // Attempt to install it. 
        bool installAccepted = Application. Current. Install(); 
 
        if (! installAccepted) 
        { 
            lblMessage. Text = 
              "You declined the install. Click Install to try again."; 
        } 
        else 
        { 
            cmdInstall. IsEnabled = false; 
            lblMessage. Text = " The application is installing. .. "; 
        } 
    } 
}

The Install() method has one potential problem: it throws an exception if the application is already installed on the local computer, even if the user is currently running the application in the browser. To avoid this error, you should check the Application.InstallState value before calling Install().

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.