How application-under-test can access its App.config upon using InProcessApplication approach?

May 19, 2010 at 4:05 PM

Hello,

We have a need to access WPF visual tree in our tests, so we need InProcessApplication control.

Following approach (using InProcessSeparateThread) fails, since the application-under-test isn't able to access its App.config file:


string workingFolder = @"D:\project\probe\UI\bin\Release"; string pathToTheApplication = Path.Combine( workingFolder, Settings.Default.ApplicationUnderTestName); pathToTheApplication = pathToTheApplication.Replace("file:\\", string.Empty); // Start the application we are testing var theApp = new InProcessApplication( new WpfInProcessApplicationSettings() { Path = pathToTheApplication, InProcessApplicationType = InProcessApplicationType.InProcessSeparateThread, ApplicationImplementationFactory = new WpfInProcessApplicationFactory() }); Directory.SetCurrentDirectory(workingFolder); theApp.Start();

Another way, using InProcessSeparateThreadAndAppDomain:

		string sampleAppPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase), "SampleApp.exe");

		sampleAppPath = sampleAppPath.Replace(@"file:\", string.Empty);
		
		var theApp = new InProcessApplication(
							new WpfInProcessApplicationSettings()
							{
								Path = sampleAppPath,
                                                                InProcessApplicationType = InProcessApplicationType.InProcessSeparateThreadAndAppDomain,
								ApplicationImplementationFactory = new WpfInProcessApplicationFactory()
								
							});
		theApp.Start();

fails as well, there is an exception upon the application-under-test start:

System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Test.ApplicationControl.WpfInProcessApplicationSettings,TestApiWpf, Version=4.0.0.0, Culture=neutral, PublicKeyToken=a069dee354d95f76'.
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyNameString typeNameBoolean ignoreCaseBindingFlags bindingAttrBinder binderObject[] argsCultureInfo cultureObject[] activationAttributesEvidence securityAttributes)
at Microsoft.Test.ApplicationControl.WpfInProcessApplicationFactory.Create(ApplicationSettings settingsAppDomain appDomain) in c:\dd\WPF_1\src\wpf\test\Infra\TestApi\TestApiWpf\Code\ApplicationControl\WpfInProcessApplicationFactory.cs: line 30
at Microsoft.Test.ApplicationControl.InProcessApplication.ApplicationStartWorker() in c:\dd\WPF_1\src\wpf\test\Infra\TestApi\TestApiCore\Code\ApplicationControl\InProcessApplication.cs: line 156
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContextContextCallback callbackObject state)
at System.Threading.ThreadHelper.ThreadStart()


So, the question is, how it's possible for the application-under-test to access its App.config upon using InProcessApplication approach?

Jan 27, 2011 at 8:38 AM

I'm having the same problem.

Did someone managed to make the InProcessSeparateThreadAndAppDomain to work?

I'm having exactly the same error but without different AppDomains, I cannot run multiple tests where each test has to start the application.