-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
@@ -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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters