[英]C# Restart Console Application
This question has been asked before but I cannot find an answer that works. 之前曾有人问过这个问题,但我找不到有效的答案。 I need to get a C# CONSOLE program to restart periodically.
我需要获取一个C# CONSOLE程序才能定期重新启动。 Each of the other answers use the Application.Restart or Application.ExecutablePath which are not supported in console apps.
其他每个答案都使用控制台应用程序不支持的Application.Restart或Application.ExecutablePath。 What code or reference can I use to restart a C# application?
我可以使用什么代码或参考来重新启动C#应用程序?
This command will work: 此命令将起作用:
System.Windows.Forms.Application.Restart();
But you need to make sure you added and referred to correctly assembly. 但是您需要确保添加并正确引用了程序集。 It's System.Windows.Forms in Assembly.
它是Assembly中的System.Windows.Forms。
Found it: 找到了:
var info = new System.Diagnostics.ProcessStartInfo(Environment.GetCommandLineArgs()[0]);
System.Diagnostics.Process.Start(info);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.