Exemple #1
0
        private static void SetupCrashHandler()
        {
            var ui       = new NormalWinFormsUserInterface();
            var settings = new DefaultSettings()
            {
                HandleProcessCorruptedStateExceptions = true,
                UserInterface = ui
            };
            var reporter = new ErrorReporter(settings);

            AppDomain.CurrentDomain.UnhandledException += reporter.UnhandledException;
            TaskScheduler.UnobservedTaskException      += reporter.UnobservedTaskException;
            Application.ThreadException += reporter.ThreadException;
        }
        static void Main()
        {
            // set NCrash handlers
            var userInterface = new NormalWinFormsUserInterface();
            var settings      = new DefaultSettings {
                UserInterface = userInterface
            };

            settings.Sender = new LocalSender();
            //Adding screenshot plugin
            settings.Plugins.Add(new ScreenShotWriter());
            var reporter = new ErrorReporter(settings);

            reporter.HandleExceptions = true;

            AppDomain.CurrentDomain.UnhandledException += reporter.UnhandledException;
            Application.ThreadException += reporter.ThreadException;
            System.Threading.Tasks.TaskScheduler.UnobservedTaskException += reporter.UnobservedTaskException;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }