diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 7431a0fc72..535352578b 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -29,8 +29,6 @@ namespace Wox [STAThread] public static void Main() { - RegisterAppDomainExceptions(); - if (SingleInstance.InitializeAsFirstInstance(Unique)) { using (var application = new App()) @@ -45,7 +43,9 @@ namespace Wox { Stopwatch.Normal("|App.OnStartup|Startup cost", () => { - Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------"); + Log.Info("|App.Main|Begin Wox startup ----------------------------------------------------"); + Log.Info($"|App.OnStartup|{ErrorReporting.RuntimeInfo()}"); + RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); ImageLoader.Initialize(); diff --git a/Wox/CrashReporter.cs b/Wox/CrashReporter.cs deleted file mode 100644 index 793cbed6de..0000000000 --- a/Wox/CrashReporter.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace Wox -{ - public class CrashReporter - { - private Exception exception; - - public CrashReporter(Exception e) - { - exception = e; - } - - public void Show() - { - if (exception == null) return; - - if (exception.InnerException != null) - { - exception = exception.InnerException; - } - ReportWindow reportWindow = new ReportWindow(exception); - reportWindow.Show(); - } - } -} diff --git a/Wox/Helper/ErrorReporting.cs b/Wox/Helper/ErrorReporting.cs index f9855350ea..8748860c4d 100644 --- a/Wox/Helper/ErrorReporting.cs +++ b/Wox/Helper/ErrorReporting.cs @@ -1,27 +1,25 @@ using System; -using System.Windows; using System.Windows.Threading; using NLog; +using Wox.Infrastructure; using Wox.Infrastructure.Exception; namespace Wox.Helper { public static class ErrorReporting { - public static void Report(Exception e) + private static void Report(Exception e) { var logger = LogManager.GetLogger("UnHandledException"); logger.Fatal(ExceptionFormatter.FormatExcpetion(e)); - new CrashReporter(e).Show(); + var reportWindow = new ReportWindow(e); + reportWindow.Show(); } public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e) { //handle non-ui thread exceptions - Application.Current.MainWindow.Dispatcher.Invoke(() => - { - Report((Exception)e.ExceptionObject); - }); + Report((Exception)e.ExceptionObject); } public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) @@ -29,5 +27,16 @@ namespace Wox.Helper //handle ui thread exceptions Report(e.Exception); } + + public static string RuntimeInfo() + { + var info = $"\nWox version: {Constant.Version}" + + $"\nOS Version: {Environment.OSVersion.VersionString}" + + $"\nIntPtr Length: {IntPtr.Size}" + + $"\nx64: {Environment.Is64BitOperatingSystem}" + + $"\nPython Path: {Constant.PythonPath}" + + $"\nEverything SDK Path: {Constant.EverythingSDKPath}"; + return info; + } } } diff --git a/Wox/ReportWindow.xaml.cs b/Wox/ReportWindow.xaml.cs index 93fbb08cb7..fa2b0fb929 100644 --- a/Wox/ReportWindow.xaml.cs +++ b/Wox/ReportWindow.xaml.cs @@ -6,6 +6,7 @@ using System.Text; using System.Linq; using System.Windows; using System.Windows.Documents; +using Wox.Helper; using Wox.Infrastructure; using Wox.Infrastructure.Logger; @@ -26,18 +27,13 @@ namespace Wox var directory = new DirectoryInfo(path); var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); - var paragraph = Hyperlink("Please open new issue in: " , Constant.Issue); + var paragraph = Hyperlink("Please open new issue in: ", Constant.Issue); paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); paragraph.Inlines.Add($"2. copy below exception message"); ErrorTextbox.Document.Blocks.Add(paragraph); StringBuilder content = new StringBuilder(); - content.AppendLine($"Wox version: {Constant.Version}"); - content.AppendLine($"OS Version: {Environment.OSVersion.VersionString}"); - content.AppendLine($"IntPtr Length: {IntPtr.Size}"); - content.AppendLine($"x64: {Environment.Is64BitOperatingSystem}"); - content.AppendLine($"Python Path: {Constant.PythonPath}"); - content.AppendLine($"Everything SDK Path: {Constant.EverythingSDKPath}"); + content.AppendLine(ErrorReporting.RuntimeInfo()); content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); content.AppendLine("Exception:"); content.AppendLine(exception.Source); @@ -54,7 +50,7 @@ namespace Wox var paragraph = new Paragraph(); paragraph.Margin = new Thickness(0); - var link = new Hyperlink {IsEnabled = true}; + var link = new Hyperlink { IsEnabled = true }; link.Inlines.Add(url); link.NavigateUri = new Uri(url); link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString()); diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 6887413f89..898e665bad 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -158,7 +158,6 @@ Properties\SolutionAssemblyInfo.cs -