用我自己的C#代码自动重启出现“停止工作错误”的程序

时间:2019-05-25 12:20:06

标签: c# list restart

我有一个程序不是我的代码。有时会出错。而且我手动关闭并重新启动程序。但是,当出现“您想调试停止工作”错误时,我想自动重新启动。如何使用自己的C#代码来制作它。

1 个答案:

答案 0 :(得分:-3)

好吧,您可以使用Application.Restart()

编辑:

 try
        {
            //run the program again and close this one
            Process.Start(Application.StartupPath + "\\blabla.exe"); 
            //or you can use Application.ExecutablePath

            //close this one
            Process.GetCurrentProcess().Kill();
        }
        catch
        { }