ClickOnce应用程序无法通过带有与ClickOnce应用程序相关联的* .abc的Process.Start(“ x.abc”)来启动 [英] ClickOnce application does not start through Process.Start("x.abc") with *.abc associated to the ClickOnce application

查看:121
本文介绍了ClickOnce应用程序无法通过带有与ClickOnce应用程序相关联的* .abc的Process.Start(“ x.abc”)来启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功开发并部署了一个ClickOnce应用程序,该应用程序注册了一个关联的文件扩展名,例如 *。abc 。当我单击名为 x.abc 的文件时,或者在命令提示符下键入 x.abc 时,ClickOnce应用程序启动,我可以通过专用API检索文件。我还可以使用以下代码以编程方式启动应用程序:

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");

在Windows Vista 64位框中,一切正常。

Everything works fine on my Windows Vista 64 bit box.

但是,如果我尝试在Windows 7(也是64位)上执行完全相同的操作,则会遇到一个非常奇怪的问题。这是我观察到的情况:

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:


  1. 手动将 x.abc 开头为-

  2. 从命令提示符处手动启动 x.abc 即可。

  3. Process.Start( x.abc)无法启动应用程序;但是,返回的过程对象表明没有错误,并且ClickOnce应用程序以某种方式立即退出。但是,即使在ClickOnce应用程序的最开始也没有达到 Trace

  4. 陌生人,进程.Start( x.bat)与文件 x.bat 包含单行 x.abc 也不会启动ClickOnce应用程序!从资源管理器开始使用相同的 x.bat (当然)。

  1. Manual start of x.abc by double-clicking it from the Explorer works.
  2. Manual start of x.abc from the command prompt works.
  3. 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 a Trace at the very beginning of the ClickOnce application is never reached.
  4. Stranger yet, Process.Start("x.bat") with a file x.bat containing the single line x.abc does not start the ClickOnce application either! Same x.bat started from the Explorer works (of course).

尝试分析 ProcMon 发生的情况不是很有帮助,因为从我的角度来看,启动应用程序的ClickOnce过程非常困难。我观察到 rundll32 开始工作,但是没有任何失败的证据。

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.

正在执行 Process.Start 是一个完全没有花哨的完全信任的控制台应用程序。

The program which is doing the Process.Start is a full trust console application with really nothing fancy.

我看不到相对于如何在Windows 7上处理ClickOnce应用程序,以及为什么 Process.Start 不会与从资源管理器启动文件完全一样。值得一提的是,将 Start 方法的更高级版本与 ProcessStartInfo 一起使用并设置 UseShellExecute true 也没有帮助。

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.

开始 cmd Process.Start 然后尝试启动 x.abc 时,显示出完全相同的问题。如果将环境设置与手动启动的 cmd 进行比较,则会发现 ProgramFiles 的定义方式存在差异(第一个指向 C:\Program Files(x86),而第二个指向 C:\Program Files )。从.NET应用程序启动的应用程序在32位仿真层(SysWoW64)上启动。

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).

我能够重现%windir%\SysWoW64\cmd.exe )来> x.abc ),然后在提示符下键入 x.abc 。我还发现了一个丑陋的解决方法,即通过启动%windir%\Sysnative\cmd.exe / C x.abc 从32位环境中启动64位命令提示符。 code>而不是 x.abc

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.

但是我宁愿使用干净的方法(或者有Microsoft代表告诉我,这确实是Windows 7和/或ClickOncce的问题,它将很快得到解决。)。

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).

推荐答案

我提出了一个基于.BAT的解决方案,该解决方案易于实现。假设您要启动与 *。abc 文件关联的ClickOnce应用程序,则只需放入一个具有相同名称但带有 *的文件.bat 扩展名放在同一文件夹中,然后执行批处理文件。这是批处理脚本:

I've come up with a .BAT based solution, which is easy to implement. Say that you want to launch the ClickOnce application associated with *.abc files, then you simply put a file with the same name, but with the *.bat extension in the same folder, and then execute the batch file instead. Here is the batch script:

if exist "%windir%\sysnative\cmd.exe" goto :mode64bit

rem For a file named "C:\foo\xyz.bat", this will generate the corresponding
rem "C:\foo\xyz.abc" file, built as the concatenation of the drive (%~d0),
rem the folder (%~p0) and the file name (%~n0), plus ".abc":

"%~d0%~p0%~n0.abc"
goto :end

:mode64bit

rem When running in a 32-bit emulation environment on a real 64-bit system,
rem start the 64-bit version of CMD.EXE, and make if start the ".abc" file
rem for us:

C:\Windows\sysnative\cmd.exe /c "%~d0%~p0%~n0.xgen"

:end

这可以直接在 *。abc 文件的调用者中实现,但有时批处理文件有助于过渡。 ..

This could be implemented directly in the caller of the *.abc files, but sometimes a batch file helps in the transition...

这篇关于ClickOnce应用程序无法通过带有与ClickOnce应用程序相关联的* .abc的Process.Start(“ x.abc”)来启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆