I'm running into a tricky little problem. I have a compiled C# executable that is called with arguments in a batch file. I would like to run this executable through the VS2012 debugger, however I am unsure of how to attach the debugger to the executable as it is run from the batch script.
I am not able to set the batch script as the project's debug startup file (only .exes), and the only process I can find that is associated with the batch file is cmd.exe, which does not allow for debugging. I have added a pause
to the beginning of the batch script so ideally the process should be running and I should be able to attach it, but I can't find anything of the expected name.
Anyone know how to do this? It seems like a pretty straightforward problem but I can't quite figure out how to get it into the debugger.
Or simply add a Debugger.Launch()
at the start of your code:
System.Diagnostics.Debugger.Launch();
It will prompt you with all available VS debuggers, choose the one your are currently using.
See link for more information: http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.launch(v=vs.110).aspx
Add this line:
System.Diagnostics.Debug.Fail("stopping!");
to a good place in your code. Run your app. Hit "Retry" and you should be prompted for a debugger. Choose Visual Studio.
Edit:
jp.gauthier's solution to use System.Diagnostics.Debugger.Launch();
is much cleaner. Upvote his instead. :)
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