How do I restart a WPF application?
I found this:
It works.
But.
Is there any better way?
System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
Application.Current.Shutdown();
WPF application restart
You should try to get the process rather than the assembly, which can return a .dll.
Restart the current application:
var currentExecutablePath = Process.GetCurrentProcess().MainModule.FileName;
Process.Start(currentExecutablePath);
Application.Current.Shutdown();
Restart application using C#
I don't think there's a direct method in WPF like there is in WinForms. However, you could use methods from the Windowns.Form
namespace like this: (You might need to add a reference to the System.Windows.Form
assembly)
System.Windows.Forms.Application.Restart();
System.Windows.Application.Current.Shutdown();
Restart WPF application after click-once update (start the new version)
There are a few ways but most don't work correctly, they end up reopening the old version.
It's going to sound crazy that WPF doesn't have a proper way to handle it (#fixwpf), but you'll need to reference System.Windows.Forms.dll
and call System.Windows.Forms.Application.Restart();
A quick search found Rob Relyea's post about the same thing (XAML, WPF Microsoft Guy)
http://robrelyea.wordpress.com/2007/07/24/application-restart-for-wpf/
Related Topics
C# Sending Mails with Images Inline Using Smtpclient
Using the Null-Conditional Operator on the Left-Hand Side of an Assignment
Double Buffering When Not Drawing in Onpaint(): Why Doesn't It Work
Facebook/ Twitter with Dotnetopenauth
HTML Agility Pack Strip Tags Not in Whitelist
Why Is Valuetype.Gethashcode() Implemented Like It Is
How to Copy Part of an Array to Another Array in C#
Create Bitmap from a Byte Array of Pixel Data
How to Compare Values of Generic Types
"Parameter Not Valid" Exception Loading System.Drawing.Image
Appending an Existing Xml File with Xmlwriter
Fastest Way to Interface Between Live (Unsaved) Excel Data and C# Objects