1

Closed

Run NUnit sample from v0.3 and v0.4 ==> FailedSystem.InvalidOperationException: No process is associated with this object.

description

TestAPI 0.3, NUnit Sample.
 
I'm getting following upon an attempt to run VerifyWindowAppearance() test :
 
VisualVerificationTests.VerifyWindowAppearance : FailedSystem.InvalidOperationException: No process is associated with this object.
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_HasExited()
at Microsoft.Test.ApplicationControl.UIAutomationApplicationImpl.Close() in c:\dd\WPF\src\wpf\test\Infra\TestApi\TestApiWpf\Code\ApplicationControl\UIAutomationApplicationImpl.cs: line 185
at Microsoft.Test.ApplicationControl.AutomatedApplication.Close() in c:\dd\WPF\src\wpf\test\Infra\TestApi\TestApiCore\Code\ApplicationControl\AutomatedApplication.cs: line 183
at VisualVerificationTests.VerifyWindowAppearance() in VisualVerificationTests.cs: line 76
 
 
Note: the application is not closed.
Closed Feb 10, 2011 at 10:46 PM by ivom
NLord,Is this still an issue? If so, please rectivate.Ivo

comments

vinsibal wrote Sep 16, 2009 at 1:55 PM

I'm unable to repro this. Could you provide information about the machine config and any other related info. Does this repro under the MSTest or xUnit?

NLord wrote Sep 16, 2009 at 3:28 PM

"Does this repro under the MSTest or xUnit?" - no, as summary and description says it's about NUnit sample.

vinsibal wrote Sep 16, 2009 at 6:33 PM

Can't assume that the summary meant it works in MSTest or xUnit. Anyway, machine config?

NLord wrote Sep 17, 2009 at 7:07 AM

"Can't assume that the summary meant it works in MSTest or xUnit. " - Ok, sorry, it was a classical misunderstanding. Anyway it fails both under NUnit and MSTest, but stack-traces are a bit different:

MSTest:
Test method VisualVerificationTests.VerifyWindowAppearance threw exception: System.InvalidOperationException: No process is associated with this object..
System.Diagnostics.Process.EnsureState(State state)
System.Diagnostics.Process.get_HasExited()
Microsoft.Test.ApplicationControl.UIAutomationApplicationImpl.Close() in c:\dd\WPF\src\wpf\test\Infra\TestApi\TestApiWpf\Code\ApplicationControl\UIAutomationApplicationImpl.cs: line 185
Microsoft.Test.ApplicationControl.AutomatedApplication.Close() in c:\dd\WPF\src\wpf\test\Infra\TestApi\TestApiCore\Code\ApplicationControl\AutomatedApplication.cs: line 183

VisualVerificationTests.VerifyWindowAppearance() in D:\TestApi v0.3\Samples\MSTest\Tests\VisualVerificationTests.cs: line 78

NUnit:

VisualVerificationTests.VerifyWindowAppearance : FailedSystem.InvalidOperationException: No process is associated with this object.
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_HasExited()
at Microsoft.Test.ApplicationControl.UIAutomationApplicationImpl.Close() in c:\dd\WPF\src\wpf\test\Infra\TestApi\TestApiWpf\Code\ApplicationControl\UIAutomationApplicationImpl.cs: line 185
at Microsoft.Test.ApplicationControl.AutomatedApplication.Close() in c:\dd\WPF\src\wpf\test\Infra\TestApi\TestApiCore\Code\ApplicationControl\AutomatedApplication.cs: line 183
at VisualVerificationTests.VerifyWindowAppearance() in VisualVerificationTests.cs: line 84

As for the config:
WinXP SP2,
VS 2008,
ReSharper 4.1,
NUnit 2.5.0
Are there any other parameters you would need to now?

NLord wrote Sep 17, 2009 at 7:18 AM

According to the stack-trace it fails at

a.Close();

call in the finally clause.

taoliu212 wrote Sep 24, 2009 at 6:22 PM

I also got the same exception when running VisualVerificationTests.VerifyWindowAppearance on WinXP SP3, VS2008, NUnit 2.4.8.
My workaround is add the following line
sampleAppPath = sampleAppPath.Replace("file:\", string.Empty);
after VisualVerificationTests.cs line 31

alexisr wrote Sep 24, 2009 at 7:29 PM

Thanks a lot for reporting this; we're tracking it in our internal database and plan to have this fixed for the next release.

NLord wrote Dec 9, 2009 at 5:13 PM

Please have a look:
I'm getting similar InvalidOperationException running VerifyWindowAppearance test from v0.4 samples (see details below).
The config of the workstation is the same is
WinXP SP2,
VS 2008,
ReSharper 4.5,
NUnit 2.5.0

The work-around suggested by taoliu212 (the replacing) does work for the sample.

VisualVerificationTests.VerifyWindowAppearance : FailedSystem.InvalidOperationException: No process is associated with this object.
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_HasExited()
at Microsoft.Test.ApplicationControl.UIAutomationApplicationImpl.Close() in c:\dd\WPF_1\src\wpf\test\Infra\TestApi\TestApiWpf\Code\ApplicationControl\UIAutomationApplicationImpl.cs: line 185
at Microsoft.Test.ApplicationControl.AutomatedApplication.Close() in c:\dd\WPF_1\src\wpf\test\Infra\TestApi\TestApiCore\Code\ApplicationControl\AutomatedApplication.cs: line 183
at VisualVerificationTests.VerifyWindowAppearance() in VisualVerificationTests.cs: line 81

NLord wrote Dec 10, 2009 at 9:10 AM

Update, sorry for possible misleading:
The work-around suggested by taoliu212 (the replacing) does work for the sample.
It works only for the test, i.e. it allows the test to be run and pass itself, but 'InvalidOperationException' still exist upon calling .Close();
Additional details:

Upon debugging the VerifyWindowAppearance() test from NUnit samples I'm getting 'InvalidOperationException'
at line 45 ( a.WaitForMainWindow(TimeSpan.FromSeconds(10));)
in 'UIAutomationApplicationImpl' class
in 'OnActivated(object sender, EventArgs e)' method
at line 220:

this.MainWindow = AutomationElement.FromHandle(Process.MainWindowHandle);

Exception details:

System.InvalidOperationException was unhandled by user code
Message="No process is associated with this object."
Source="System"
StackTrace:
   at System.Diagnostics.Process.EnsureState(State state)
   at System.Diagnostics.Process.EnsureState(State state)
   at System.Diagnostics.Process.EnsureState(State state)
   at System.Diagnostics.Process.get_MainWindowHandle()
   at Microsoft.Test.ApplicationControl.UIAutomationApplicationImpl.OnActivated(Object sender, EventArgs e) in c:\dd\WPF_1\src\wpf\test\Infra\TestApi\TestApiWpf\Code\ApplicationControl\UIAutomationApplicationImpl.cs:line 220
   at MS.Internal.Automation.InvokeHandlers.InvokeClientHandler(Delegate clientCallback, AutomationElement srcEl, AutomationEventArgs args)
InnerException:

wrote Feb 10, 2011 at 10:46 PM

wrote Feb 14, 2013 at 9:08 PM

wrote May 16, 2013 at 11:02 AM