I have successfully developed and deployed a ClickOnce application which registers an associated file extension, for instance *.abc
. When I click on a file named x.abc
or if I type x.abc
from the command prompt, the ClickOnce application starts, and I can retrieve the file through the dedicated API. I can also launch the application programmatically with the following code:
System.Diagnostics.Process.Start ("x.abc");
Everything works fine on my Windows Vista 64 bit box.
However, if I try to do exactly the same thing on a Windows 7 (also 64 bit ), I have a very strange problem. Here is what I observe:
- Manual start of
x.abc
by double-clicking it from the Explorer works. - Manual start of
x.abc
from the command prompt works. Process.Start("x.abc")
does not start the application; however, the process object returned shows that there was not error and that the ClickOnce application somehow exited immediately. But even aTrace
at the very beginning of the ClickOnce application is never reached.- Stranger yet,
Process.Start("x.bat")
with a filex.bat
containing the single linex.abc
does not start the ClickOnce application either! Samex.bat
started from the Explorer works (of course).
Trying to analyse what happens with ProcMon
was not very helpful, as the ClickOnce process of launching an application is very difficult to follow, from my point of view. I observe rundll32
getting to work, but no evidence of any failure.
The program which is doing the Process.Start
is a full trust console application with really nothing fancy.
I can't see what changed with respect to how ClickOnce applications are handled on Windows 7 and why Process.Start
would not do exactly the same as launching the file from Explorer. It's worth to mention that using more advanced versions of the Start
method with ProcessStartInfo
and setting UseShellExecute
to true
did not help either.
Starting cmd
with Process.Start
and then trying to launch x.abc
shows exactly the same problem. If I compare the environment settings with a cmd
started manually, I see differences in how ProgramFiles
is defined (the first one points to C:\Program Files (x86)
whereas the second points to C:\Program Files
). The applications started from my .NET application are started on the 32-bit emulation layer (SysWoW64).
I was able to reproduce the launch failure of x.abc
by starting a 32-bit version of the command prompt (that is, %windir%\SysWoW64\cmd.exe
) and then typing x.abc
at the prompt. I have also found an ugly workaround, which is to start a 64-bit command prompt from the 32-bit environment by launching %windir%\Sysnative\cmd.exe /C x.abc
instead of x.abc
.
But I'd rather use a clean way of doing it (or have a Microsoft representative tell me that this is indeed an issue with Windows 7 and/or ClickOncce and that it will be fixed soon).