unnamed
unnamed

Reputation: 113

How to restart console app c# mono MacOS

I use Visual Studio for MacOS.

How to restart console application when i catch exceptions?

Windows code not work:

                try
                {

                }
                catch (Exception)
                {
                    Process.Start(Assembly.GetExecutingAssembly().Location);
                    Environment.Exit(0);
                }

Upvotes: 0

Views: 516

Answers (1)

Aksel482
Aksel482

Reputation: 46

You can try to use this code for restarting the project but i recommend you to start this project on the .exe it may not work on visual studio.

try
{
     //"The code you wanna try"
}
catch
{
     System.Diagnostics.Process.Start(Environment.GetCommandLineArgs()[0], Environment.GetCommandLineArgs().Length > 1 ? string.Join(" ", Environment.GetCommandLineArgs().Skip(1)) : null);</i>
}

Upvotes: 1

Related Questions