[英]How to restart console app c# mono MacOS
我使用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>
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.