WPF应用程序重新启动

Exa*_*ken 2 c# wpf restart

我必须重新启动应用程序。当我用谷歌搜索它时,我发现 这个和其他几个建议这个代码:

System.Diagnostics.Process.Start(Application.ResourceAssembly.Location); System.Windows.Application.Current.Shutdown();

但它所做的只是关闭应用程序。我在 Visual Studio 中尝试过,只执行 bin 文件夹中的 exe,但结果总是一样。该项目是.NET Core WPF。还有其他想法或想法可能是什么问题吗?

Bio*_*ode 13

您应该尝试获取进程而不是程序集,它可以返回.dll

重新启动当前应用程序:

var currentExecutablePath = Process.GetCurrentProcess().MainModule.FileName;
Process.Start(currentExecutablePath);
Application.Current.Shutdown();
Run Code Online (Sandbox Code Playgroud)