How can I restart my WPF application using C#?
You can simply use a do ... while loop (including your program source code). do { /* Get user input. */ } while (a <= 0);
ANSWER. You may typecast the address of the reset vector (0x0000) to a function pointer and call that from C using the following: ((void (code *) (void)) 0x0000) (); For example, the following program continuously resets itself.
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();
The following is the best solution I found, you don't need to add a reference to System.Windows.Forms, instead you need add the namespace System.Diagnostics
which you already has a reference to its assembly:
Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With