How do I restart a WPF application? [duplicate]

How can I restart a WPF Application? In windows Forms I used

System.Windows.Forms.Application.Restart();

How to do it in WPF?


I found this: It works. But. Is there any better way?

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

I've used this in WPF, successfully:

System.Windows.Forms.Application.Restart();
System.Windows.Application.Current.Shutdown();

Runs a new instance of the program by command line after 1 second delay. During the delay current instance shutdown.

ProcessStartInfo Info = new ProcessStartInfo();
Info.Arguments = "/C choice /C Y /N /D Y /T 1 & START \"\" \"" + Assembly.GetEntryAssembly().Location + "\"";
Info.WindowStyle = ProcessWindowStyle.Hidden;
Info.CreateNoWindow = true;
Info.FileName = "cmd.exe";
Process.Start(Info);
Process.GetCurrentProcess().Kill();

EDIT:

I fixed the code:

instead of: Assembly.GetExecutingAssembly().Location

this: Assembly.GetEntryAssembly().Location

This is important when the function runs in a separate dll.

And -

instead of: Application.Current.Shutdown();

this: Process.GetCurrentProcess().Kill();

It will work both in WinForms and in WPF and if you write a dll that is designed for both then it is very important.