【发布时间】:2013-11-14 04:42:04
【问题描述】:
我正在尝试使用 Process.Start 启动 wpf 应用程序。当我通过在explorer.exe 中双击它来启动该进程时,它会正确启动;但是,当我尝试使用以下代码 sn-p 时:
var programPath = @"C:\Users\user\Documents\Program Directory\program.exe";
if(!File.Exists(programPath))
{
MessageBox.Show("The program.exe file does not exist! Cannot launch.");
return;
}
Process.Start(programPath);
我的 WPF 进程在任务管理器中短暂闪烁,然后立即关闭。
【问题讨论】:
-
您的应用程序崩溃了吗?只需在 Windows 中查看应用程序日志....
-
@dbw 我不确定它是否崩溃,但我很确定它不应该因为我可以自行启动它......
-
您的应用程序是否依赖于工作文件夹中的其他文件?如果是这样,请确保将该信息添加到 Start() 方法
-
如果您的应用程序崩溃然后处理 App_DispatcherUnhandledException。