In your main
method, add a Try...Catch...Finally
block, as shown:
This will ensure that all exceptions you receive are displayed and that the user will need to take measures to close the command window.
try { // Your existing code } catch (Exception e) { // Log the exception, eg: Console.WriteLine(e.ToString()); } finally { Console.WriteLine ("Please press any key to close"); Console.ReadKey(); }
source share