Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何重新启动控制台应用程序c#mono MacOS_C#_Macos_Mono - Fatal编程技术网

如何重新启动控制台应用程序c#mono MacOS

如何重新启动控制台应用程序c#mono MacOS,c#,macos,mono,C#,Macos,Mono,我使用Visual Studio for MacOS 捕获异常时如何重新启动控制台应用程序 Windows代码不工作: try { } catch (Exception) { Process.Start(Assembly.GetExecutingAssembly().Location);

我使用Visual Studio for MacOS

捕获异常时如何重新启动控制台应用程序

Windows代码不工作:

                try
                {

                }
                catch (Exception)
                {
                    Process.Start(Assembly.GetExecutingAssembly().Location);
                    Environment.Exit(0);
                }

您可以尝试使用此代码重新启动项目,但我建议您在.exe上启动此项目。它可能无法在visual studio上运行

try
{
     //"The code you wanna try"
}
catch
{
     System.Diagnostics.Process.Start(Environment.GetCommandLineArgs()[0], Environment.GetCommandLineArgs().Length > 1 ? string.Join(" ", Environment.GetCommandLineArgs().Skip(1)) : null);</i>
}
试试看
{
//“你想试试的代码”
}
抓住
{
System.Diagnostics.Process.Start(Environment.GetCommandLineArgs()[0],Environment.GetCommandLineArgs().Length>1?string.Join(“,Environment.GetCommandLineArgs().Skip(1)):null);
}

要使用mono启动应用程序,您需要运行[mono xxx.exe],而不是直接调用exe名称。@scegg,“/Users/mac/Projects/Taxi2PartnerMac/Taxi2PartnerMac/bin/Debug/Taxi2PartnerMac.exe”抱歉,我刚刚编辑了我的评论。您可以尝试启动mono作为进程,并将此位置作为参数传递。@scegg,我尝试执行它的字符串path=“mono”+Assembly.getExecutionGassembly().location;进程启动(路径);是的,我从terminalCan运行.exe程序。您可以只在主字符串上尝试代码,以便我们了解代码是否有效。我的意思是,不要在try,catch.the代码中使用它。相同的工作过程。Start(Assembly.getexecutinggassembly().Location);环境。退出(0);