Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Register a Client-Side Provider Assembly

Note Note

This documentation is intended for .NET Framework developers who want to use the managed UI Automation classes defined in the System.Windows.Automation namespace. For the latest information about UI Automation, see Windows Automation API: UI Automation.

This topic shows how to register a DLL that contains client-side UI Automation providers.

The following example shows how to register an assembly that contains a provider for a console window.

using System;
using System.Windows.Automation;
using System.Reflection;
using System.Runtime.InteropServices;    // for DllImport 
using System.IO;

namespace CSClient
    class CSClientProgram
        static extern IntPtr GetConsoleWindow();

        static void Main(string[] args)
            // TODO  Change the path to the appropriate one for your CSProviderDLL. 
            string fileloc = @"C:\SampleDependencies\CSProviderDLL.dll";
            Assembly a = null;
                a = Assembly.LoadFile(fileloc);
            catch (FileNotFoundException e1)

            if (a != null)
                catch (ProxyAssemblyNotLoadedException e)

                IntPtr hwnd = GetConsoleWindow();

                // Get an AutomationElement that represents the window. 
                AutomationElement elementWindow = AutomationElement.FromHandle(hwnd);
                Console.WriteLine("Found UI Automation client-side provider for:");

                // The name property is furnished by the client-side provider.
            Console.WriteLine("Press any key to exit.");
© 2015 Microsoft