示例#1
0
        private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;
            Journal.WriteLog(e.Exception, JournalEntryType.Error);

            DXMessageBox.Show(e.Exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
        }
示例#2
0
 public static T GetSerializedObject <T>(Stream stream)
 {
     try
     {
         DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
         return((T)serializer.ReadObject(stream));
     }
     catch (Exception ex)
     {
         Journal.WriteLog(ex, JournalEntryType.Error);
         return(default(T));
     }
 }
示例#3
0
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                string message = String.Format("A fatal error has occurred in the application.\nSorry for the inconvenience.\n\n{0}:\n{1}",
                                               e.ExceptionObject.GetType(), e.ExceptionObject.ToString());

                if (e.ExceptionObject is Exception)
                {
                    Journal.WriteLog(e.ExceptionObject as Exception, JournalEntryType.Fatal);
                }
                else
                {
                    Journal.WriteLog("Fatal Error: " + message, JournalEntryType.Fatal);
                }

                DXMessageBox.Show(message, "Fatal Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Environment.Exit(-1);
            }
        }