C#无法在发布后加载嵌入式EXE

时间:2014-12-09 18:40:35

标签: c# publish embedded-resource relative-path

我正在将EXE文件集成到我的C#桌面应用程序中(当我搜索我的问题时,结果与网络应用程序相关)。

我使用以下命令在调试模式下运行它,它运行正常。

Process exeProcess = Process.Start("Test.exe");

但是,当我想发布应用程序时会出现问题:

 ************** Exception Text **************
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()

我将exe文件添加到项目中,并将复制到输出目录设置为复制始终,并且test.exe.deploy与我的数据库文件一起存在于已部署的应用程序文件夹中,但我仍然得到相同的错误。

因为,我对我的数据库使用相同的方法:

|DataDirectory|\UserData.mdf

我试过用相对路径运行exe:

string path = Directory.GetCurrentDirectory(); string rel= Path.Combine(path, "test.exe"); Process exeProcess = Process.Start(rel);

但是,仍然没有运气!

我做错了什么?或者有更好的方法吗?

0 个答案:

没有答案