【发布时间】:2014-03-18 12:04:53
【问题描述】:
我有一个程序,它是用于制作课程的创作工具。我决定使用 camstudio 为其创建屏幕录制功能。我用来启动exe的代码是:
Process process = new Process();
process.StartInfo.FileName = "Recorder.exe";
process.StartInfo.Arguments = "";
process.Start();
当我在 Visual Studio 中运行该程序并逐步执行代码时,它运行良好,并且可以正常启动 recorder.exe。但是当我在 Visual Studio 2010 中为项目制作安装程序并安装程序时,当我按下应该启动 recorder.exe 的按钮时程序崩溃。
我检查了 Windows 错误日志,这是它告诉我的:
应用程序:Perform.exe 框架版本:v4.0.30319 描述: 由于未处理的异常,该进程被终止。 异常信息:System.ComponentModel.Win32Exception 堆栈:在 System.Diagnostics.Process.StartWithShellExecuteEx(System.Diagnostics.ProcessStartInfo) 在 System.Diagnostics.Process.Start() 在 P2Designer.Window1.scriptUpdatePerform(System.Object, System.Windows.RoutedEventArgs)在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)在 System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs,布尔值)在 System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)在 System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs) 在 DevComponents.WpfRibbon.ButtonDropDown.OnClick() 在 DevComponents.WpfRibbon.ButtonDropDown.x984587de9d70aaba(System.Object) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate、System.Object、Int32、System.Delegate)在 System.Windows.Threading.DispatcherOperation.InvokeImpl() 在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) 在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback,System.Object,布尔值)在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback,System.Object,布尔值)在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback,System.Object)在 System.Windows.Threading.DispatcherOperation.Invoke() 在 System.Windows.Threading.Dispatcher.ProcessQueue() 在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr,Int32,IntPtr, IntPtr, Boolean ByRef) 在 MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) 在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate、System.Object、Int32、System.Delegate)在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) 在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr,Int32,IntPtr,IntPtr) 在 MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)在 System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) 在 System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) 在 System.Windows.Threading.Dispatcher.Run() 在 System.Windows.Application.RunDispatcher(System.Object) 在 System.Windows.Application.RunInternal(System.Windows.Window) 在 System.Windows.Application.Run(System.Windows.Window) 在 System.Windows.Application.Run() 在 P2Designer.App.Main()
在这里找到了一个类似的未回答问题:Why i'm getting a win32exception once i'm starting the Process?
如果需要更多信息,请告诉我,我会尽可能提供。我在这里和其他论坛上看到过类似的问题,但没有人给我答案。 谢谢,吉姆
【问题讨论】:
-
你能在 Win32Exception 中加入一些错误处理来捕获并记录 Message 和 ErrorCode 吗?错误代码尤其会提供有关问题所在的更多信息。另外,你能告诉我们以管理员身份运行程序时的行为是什么吗?我怀疑存在权限相关问题。
-
我以非管理员身份和管理员身份运行,并且两者都出现相同的错误。我现在将继续进行错误处理
-
我得到:System.ComponentModel.Win32Exception(0x800004005):系统找不到指定的文件...。很确定我提供的路径是正确的。设置安装程序时我做错了什么吗?我必须以特殊方式添加exe吗?
标签: c# process installation exe