This project is read-only.


In-Process control, start application ==> app.MainWindow = null


Could you please clarify following about In-Process control?
I'm trying to start my application using EXAMPLE #2 from the Concepts.doc, so my code is:


InProcessSettings ips = new InProcessSettings("D:\prj\TheApplication.exe",
AutomatedApplication a = AutomatedApplication.Start(ips);


Upon execution I get a.MainWindow = null.
So, the question is - am I missing something for starting target application using in-process control?
Closed Feb 10, 2011 at 10:48 PM by ivom
Closing, as the issue has been resolved.


nancy_jiang wrote Jul 22, 2009 at 7:42 AM

hi ,I meet the same question too....

vinsibal wrote Sep 16, 2009 at 1:50 PM

EXAMPLE #2 is a little different than what you posted:

var a = new InProcessApplication(new InProcessApplicationSettings
    Path = @"c:\WpfTestApplication.exe",
    InProcessApplicationType = InProcessApplicationType.InProcSeparateThread
a.MainWindowOpened += (s, e) => { / ... / };
a.Exited += (s2, e2) => { / ... / };


// Wait for WpfTestApplication to display its main window
// Wait up to 5 seconds.

// ...
// Perform additional actions on the application... e.g. simulate input, etc.
// Then, after we are done, close the application.

Have you tried that?

NLord wrote Sep 16, 2009 at 3:27 PM

Hello, as you probably saw from the initial post date, it's related to TestAPI v0.2 and the issue is reproducible for me. As for v0.3 - just haven't managed to get it work stable, see recent post here.

wrote Sep 30, 2009 at 5:05 PM

Budda wrote Jan 27, 2010 at 12:47 PM

I have the same problem:
        string sampleAppPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase), "WpfTest1.exe");
        AutomatedApplication a = new OutOfProcessApplication(new OutOfProcessApplicationSettings
                                                                     ProcessStartInfo =new ProcessStartInfo(sampleAppPath),
                                                                     ApplicationImplementationFactory =new UIAutomationOutOfProcessApplicationFactory()

        var mainWindow = a.MainWindow as AutomationElement;
Here mainWindow is null... why?

P.S. I am using 0.4 TestAPI version

Budda wrote Jan 27, 2010 at 1:02 PM

If I tried to use "InProcess" application that is given here:
        a = new InProcessApplication(new InProcessApplicationSettings
            Path = sampleAppPath,
            InProcessApplicationType = InProcessApplicationType.InProcessSeparateThread
I've got the error

ApplicationImplementationFactory must be specified..

Question: what should be assigned to the "ApplicationImplementationFactory" Property?


wrote Jan 27, 2010 at 1:14 PM

Budda wrote Jan 27, 2010 at 2:41 PM

I've resolved my problem: my application requires additional assemblies, so they should were to be added into test project too.

When I did that I've got my application to be tested launched and open and have also got another problem:

an error is occured in the UIAutomationApplicationImpl.OnActivated method:
         No process is associated with this object.
in the line:
        this.MainWindow = AutomationElement.FromHandle(Process.MainWindowHandle);
It is occured after the following code execution:
        string sampleAppPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase),

        AutomatedApplication a;
        a = new OutOfProcessApplication(new OutOfProcessApplicationSettings
                ProcessStartInfo = new ProcessStartInfo(sampleAppPath),
                ApplicationImplementationFactory = new UIAutomationOutOfProcessApplicationFactory()

I will appreciated if there is any thoughts why that occured and how to resolve/workaround that.


Budda wrote Jan 28, 2010 at 9:32 AM

My issue was resolved with "file:\" exclusion.


wrote Feb 10, 2011 at 10:48 PM

wrote Feb 14, 2013 at 9:08 PM

wrote May 16, 2013 at 11:02 AM