1

The problem is that I want to restart my application to upgrade the current application. For this I am using below mentioned two lines of code.

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

Process.GetCurrentProcess().Kill();

OR

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

Application.Current.Shutdown();

But this is giving an error message of "An unhandled win32 exception is occurred". Hence this is not working.

John Smith
  • 7,243
  • 6
  • 49
  • 61
Prasanta
  • 11
  • 1
  • 2
  • possible duplicate of [How do I restart a WPF application?](http://stackoverflow.com/questions/4773632/how-do-i-restart-a-wpf-application) – Cody Gray - on strike Jan 30 '12 at 06:20
  • Posting the stack trace for the exception might be a start. What is throwing that Win32 exception? – Cody Gray - on strike Jan 30 '12 at 06:21
  • Hi Cody Gray, I have tried with [link](http://stackoverflow.com/questions/4773632/how-do-i-restart-a-wpf-application) this link. But now it is giving an error which is "An Application object is being shut down." – Prasanta Jan 30 '12 at 06:32
  • @user1177428 Where are you running the code? The code posted [here](http://stackoverflow.com/a/4773639/302677) works fine for me, but I run it before the `base.OnStartup()` call in the `OnStartup()` method of `App.xaml.cs` – Rachel Jan 30 '12 at 14:32

1 Answers1

1

Have you tried?

Application.Restart();

or

System.Diagnostics.Process.Start(Application.ExecutablePath);
Application.Exit();