Sdílet prostřednictvím


AutomationFactory.IsAvailable Property

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

Gets a value that indicates whether the Automation feature in Silverlight is available to the application.

Namespace:  System.Runtime.InteropServices.Automation
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Shared ReadOnly Property IsAvailable As Boolean
public static bool IsAvailable { get; }

Property Value

Type: System.Boolean
true if the Automation feature in Silverlight is available to the application; otherwise, false.

Remarks

You should always check this property before using the AutomationFactory class to access an Automation server.

For more information about Automation, see Automation.

Examples

The following code example demonstrates how to use this property.

This example is part of a larger example in How to: Use Automation in Trusted Applications.

Public Sub New()

    InitializeComponent()

    If AutomationFactory.IsAvailable Then

        ' Use Outlook on a background thread to keep the UI responsive.
        Dim worker As New BackgroundWorker()
        AddHandler worker.DoWork,
            Sub(sender, e)
                If InitializeOutlook() Then
                    SearchEmail()
                Else : Dispatcher.BeginInvoke(
                    Sub()
                        MessageBox.Show("Outlook is not available.")
                    End Sub)
                End If
            End Sub
        worker.RunWorkerAsync()

    Else : MessageBox.Show("Automation is not available.")
    End If

End Sub
public MainPage()
{
    InitializeComponent();
    if (AutomationFactory.IsAvailable)
    {
        // Use Outlook on a background thread to keep the UI responsive.
        BackgroundWorker worker = new BackgroundWorker();
        worker.DoWork += (sender, e) =>
        {
            if (InitializeOutlook()) SearchEmail();
            else Dispatcher.BeginInvoke(() =>
            {
                MessageBox.Show("Outlook is not available.");
            });
        };
        worker.RunWorkerAsync();
    }
    else
    {
        MessageBox.Show("Automation is not available.");
    }
}

Version Information

Silverlight

Supported in: 5, 4

Platforms

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