Home
Manage Your Code
Snippet: Breakpoint hardcoded inside try-catch in debug mode (C#)
Title: Breakpoint hardcoded inside try-catch in debug mode Language: C#
Description: This snippet shows how to force the running application to stops automatically when occurs an exception -exclusively when in debug mode Views: 320
Author: Gerson Amorim Date Added: 7/12/2012
Copy Code  
1            try
2            {
3        // your code to try
4            }
5            catch (Exception ex)
6            {
7                MessageBox.Show("Erro ao iniciar aplicativo: \n" + ex.Message + "\n" + ex.StackTrace);
8                Console.WriteLine(DateTime.Now + " - Erro : " + ex.Message + "\nStackTrace:" + ex.StackTrace);
9#if DEBUG
10                System.Diagnostics.Debugger.Break();
11#endif
12            }