Skip to content

Commit

Permalink
增加软件崩溃后的上报错误功能
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxuuu committed Jun 25, 2019
1 parent 19ee2fe commit 9e7087e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
37 changes: 36 additions & 1 deletion llcom/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using CrashReporterDotNET;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

namespace llcom
{
Expand All @@ -13,5 +15,38 @@ namespace llcom
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
Application.Current.DispatcherUnhandledException += DispatcherOnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
}

private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
{
SendReport(unobservedTaskExceptionEventArgs.Exception);
}

private void DispatcherOnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs dispatcherUnhandledExceptionEventArgs)
{
SendReport(dispatcherUnhandledExceptionEventArgs.Exception);
}

private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
{
SendReport((Exception)unhandledExceptionEventArgs.ExceptionObject);
}

public static void SendReport(Exception exception, string developerMessage = "", bool silent = false)
{
var reportCrash = new ReportCrash("[email protected]")
{
DeveloperMessage = "llcom错误报告"
};
reportCrash.Silent = silent;
reportCrash.CaptureScreen = true;
reportCrash.Send(exception);
}
}
}
4 changes: 2 additions & 2 deletions llcom/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]
[assembly: NeutralResourcesLanguage("zh-CN")]

3 changes: 3 additions & 0 deletions llcom/llcom.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<Reference Include="AdonisUI.ClassicTheme, Version=1.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AdonisUI.ClassicTheme.1.11.0\lib\net40\AdonisUI.ClassicTheme.dll</HintPath>
</Reference>
<Reference Include="CrashReporter.NET, Version=1.5.7.0, Culture=neutral, PublicKeyToken=7828e0fd88cab698, processorArchitecture=MSIL">
<HintPath>..\packages\CrashReporter.NET.Official.1.5.7\lib\net462\CrashReporter.NET.dll</HintPath>
</Reference>
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
<HintPath>..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
</Reference>
Expand Down
1 change: 1 addition & 0 deletions llcom/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<package id="AdonisUI" version="1.11.0" targetFramework="net472" />
<package id="AdonisUI.ClassicTheme" version="1.11.0" targetFramework="net472" />
<package id="AvalonEdit" version="5.0.4" targetFramework="net472" />
<package id="CrashReporter.NET.Official" version="1.5.7" targetFramework="net472" />
<package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net472" />
<package id="LibUsbDotNet" version="2.2.29" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
Expand Down

0 comments on commit 9e7087e

Please sign in to comment.