2

I have to restart an application. When I googled about it I found this and several others suggesting this code:

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

but all it did, was closing the application. I tried it within Visual Studio, and just executing the exe in the bin folder, but it always turned out the same. The project is a .NET Core WPF. Any additional ideas, or ideas what the problem could be?

ExampleWasTaken
  • 43
  • 1
  • 10
  • 1
    Does this answer your question? [Restart application using C#](https://stackoverflow.com/questions/3895188/restart-application-using-c-sharp) – Keith Stein May 16 '20 at 21:34

1 Answers1

11

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();
BionicCode
  • 1
  • 4
  • 28
  • 44