我需要通过传递补丁文件的URL来启动更新程序。基本Process.Run工作正常,但是当我通过参数时没有任何反应。 (这是Linux Mint和Mono)
我已经检查了SO,net等,并尝试过将UseShellExecute设置为false或使用ProcessStartInfo等解决方案。
我做错了什么? Updater位于main exe所在的文件夹中。 单声道控制台显示没有错误。
作品:(适合所有人,所以不出意外)
Process.Start (Application.StartupPath + @"/Updater.exe");
不起作用(没有任何事情发生,也是预料到的?):
Process.Start(Application.StartupPath + @"/Updater.exe", "URLToFile");
我尝试过的其他解决方案:
Process.Start(new ProcessStartInfo(Application.StartupPath + @"/Updater.exe", @"URLToFile.zip") { UseShellExecute = false });
我也尝试了很多解决方案: How to use Process.Start() or equivalent with Mono on a Mac and pass in arguments 我检查了一些其他博客和谷歌搜索结果。没有任何解决方案可悲地为我工作。
更多信息可能不那么重要但可以提供帮助:
我做错了什么?感谢。
答案 0 :(得分:2)
尝试前缀" mono"因为你想要以.exe作为参数运行mono。我还以另一种方式确定应用程序路径:
string sAppPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Process.Start("mono " + sAppPath + @"/Updater.exe");
答案 1 :(得分:0)
抱歉,我没有测试我的代码。现在我做了一个小项目并对其进行了测试 - 只是一个带有标签和按钮的表格。工作正常。我正在获得正确的路径,HelloWorld应用程序启动并处理CmdLineArg。核心内容来自:
private void DoIt()
{
string sAppPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = "mono";
psi.Arguments = sAppPath + @"/HelloWorld.exe CmdLineArg";
System.Diagnostics.Process.Start(psi);
}