/// <summary>
        /// Handles any exceptions that occur in child threads.
        /// By doing this, we don't get annoying JIT popups that squash our debugging efforts.
        /// </summary>
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            try
            {
                // Write out to the Debug trace if it's available (to save time)
                System.Diagnostics.Debug.WriteLine(e.Exception.ToString());

                // Create a MiniDump in the Dumps directory (also makes a WEP entry)
                CrashHandler.CreateMiniDump();

                if (m_Log != null)
                {
                    m_Log.Log(Logging.LOGTYPE.ERROR, "Checking privs in crash handler");
                }

                // We could now pop up a custom dialog if we desired
                if (IsAdmin())
                {
                    MessageBox.Show("OpenDNSCrypt has encountered an error and will now close.");
                }
                else
                {
                    MessageBox.Show("OpenDNSCrypt cannot continue because it requires administratrive priveleges to run. Please run as administrator.");
                }

                if (m_Log != null)
                {
                    m_Log.Log(Logging.LOGTYPE.ERROR, "Crash Exception: ");
                    m_Log.Log(Logging.LOGTYPE.ERROR, e.Exception.ToString());
                }

                // TODO: Throwing a new exception here gives us more info in our reports... investigate
                //throw new Exception("AHA");
            }
            finally
            {
                // We always want to exit after a crash
                Application.Exit();
            }
        }
Exemplo n.º 2
0
 void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     // Write crash dump before anything else
     CrashHandler.CreateMiniDump();
 }