Reputation: 788
I use the following code to restart my console application:
System.Diagnostics.Process.Start(Environment.GetCommandLineArgs()[0]);
Environment.Exit(0);
This works just fine when I start it directly from its built executable. But if i debug it using Visual Studio, it won't. This is because Visual Studio runs application.vhost.exe
first, which starts my application then. Now if I just run this vhost.exe
, it won't run my application. I assume I have to pass command line arguments first.
My questions are the following:
#if(DEBUG)
preprocessor directive to pass the .vhost.exe
-file arguments only when the software is debugged, but which arguments do I need to pass him to make it work properly? Also, this seems to me kind of "dirty" - Is there a better way?Upvotes: 0
Views: 2033
Reputation: 26642
1) In project properties, disable "Visual Studio Hosting Process". Then no "*.vshost.exe" will be used. 2) If you call System.Diagnostics.Debugger.Break(), the debugger selection dialog will be shown and you can select already running instance of visual studio.
Upvotes: 1