Partager via


Application.Install Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Attempts to install the application so that it can run outside the browser.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Function Install As Boolean
[SecuritySafeCriticalAttribute]
public bool Install()

Return Value

Type: System.Boolean
true if the user gave consent to install the application or the application requires elevated trust; otherwise, false. See Remarks for more information.

Exceptions

Exception Condition
InvalidOperationException

The application is already installed.

-or-

The application is hosted at a URI with a scheme other than http, https, or file.

Remarks

This method works only from within an event handler for a user-initiated event, and only if the application manifest is correctly configured to enable out-of-browser support. If these conditions are not met, this method returns false and the install dialog box is not shown. If the application requires elevated trust, this method returns true before the install dialog box is shown.

Examples

The following code example demonstrates how to use this method. This example is part of a larger example available in How to: Implement Offline Support for Out-of-Browser Applications.

Private Sub installButton_Click(ByVal sender As Object, _
    ByVal e As RoutedEventArgs)

    Try
        app.Install()
    Catch ex As InvalidOperationException
        MessageBox.Show("The application is already installed.")
    End Try

End Sub
private void installButton_Click(object sender, RoutedEventArgs e)
{
    try
    {
        app.Install();
    }
    catch (InvalidOperationException)
    {
        MessageBox.Show("The application is already installed.");
    }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.