Export (0) Print
Expand All

AutomationFactory.CreateObject Method (String)


Activates and returns a reference to the registered Automation server with the specified programmatic identifier (ProgID).

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

public static Object CreateObject(
	string progID


Type: System.String
The ProgID of the registered automation server to activate.

Return Value

Type: System.Object
A late-bound reference to the specified automation server.


No object was found registered for the specified progID.

You must assign the return value to a variable of type Object in Visual Basic and type dynamic in C#. This enables you to use the reference as a late-bound object.

For more information about Automation, see Automation.

The following code example demonstrates how to use this method.

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

private dynamic outlook;

private bool InitializeOutlook()
        // If GetObject throws an exception, then Outlook is 
        // either not running or is not available.
        outlook = AutomationFactory.GetObject("Outlook.Application"); 
        return true;
    catch (Exception)
            // Start Outlook and display the Inbox, but minimize 
            // it to avoid hiding the Silverlight application.
            outlook = 
            outlook.Session.GetDefaultFolder(6 /* Inbox */).Display();
            outlook.ActiveWindow.WindowState = 1; // minimized
            return true;
        catch (Exception)
            // Outlook is unavailable.
            return false;


Supported in: 5, 4

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

Community Additions

© 2015 Microsoft