Monday 29 October 2012

How to Include Breakpoint programmatically in Try Catch Block in Codes

How to Include Breakpoint programmatically in Try Catch Block in Codes

This snippet shows how to force the running application to stops automatically when occurs an exception -exclusively when in debug mode.


            try
            {
               // your code to try
            }
            catch (Exception ex)
            {
               MessageBox.Show("Erro ao iniciar aplicativo: \n" + ex.Message + "\n" + ex.StackTrace);
                Console.WriteLine(DateTime.Now + " - Erro : " + ex.Message + "\nStackTrace:" +   ex.StackTrace);
               #if DEBUG
                System.Diagnostics.Debugger.Break();
               #endif
            } 

1 comment:

Thank You for Your Comments. We will get back to you soon.

back to top