FAQ: Why I am not able to launch a Click-Once application using ApplicationUnderTest?

You cannot launch a Click-Once application using ApplicationUnderTest.Launch().

e.g:- ApplicationUnderTest.Launch(@"C:\Users\YourName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\LOB Apps\YourApplication.appref-ms");


This will give an error:

Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToLaunchApplicationException: The specified executable is not a valid Win32 application. File: C:\Users\YourName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\LOB Apps\YourApplication.appref-ms. ---> System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.


We have made a conscious decision to allow only executable files as arguments to ApplicationUnderTest.Launch. In the above example, appref-ms file is passed as an argument to Click Once launcher. It is not an executable file by itself. So you get the error.

NOTE: Similarly you cannot pass .txt files or .doc files as arguments to ApplicationUnderTest.Launch().


There are two workarounds for this issue.

1. Use System.Diagnostics.Process.Start(@"C:\Users\YourName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\LOB Apps\YourApplication.appref-ms");

2. Use the Coded UI Test Builder to record the launch of the click-once application. The actions recorded will be a click on the menu item for your click once application. [This is not a intent-aware recording]. Therefore this recording is less resilient and may fail if the test is run on a  different machine.