-
-
Save jdhurst/0872e8f339a132853c6d to your computer and use it in GitHub Desktop.
This is a slightly modified version of the class library 'Without User Interface', which comes with Red Gate's SmartAssembly [usually located in: /Red Gate/SmartAssembly 6/SDK/Exception Reporting/Without UI]. I've added 2 lines [22 & 23] which kill the application after logging the error.
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
using System; | |
using System.Security; | |
using SmartAssembly.SmartExceptionsCore; | |
namespace SmartAssemblyLogger | |
{ | |
public class UnhandledExceptionHandlerWithoutUI : UnhandledExceptionHandler | |
{ | |
protected override void OnSecurityException(SecurityExceptionEventArgs e) | |
{ | |
e.ReportException = true; | |
} | |
protected override void OnReportException(ReportExceptionEventArgs e) | |
{ | |
for (int i = 0; i < 3; i++) | |
{ | |
if (e.SendReport()) break; | |
} | |
e.TryToContinue = false; | |
System.Diagnostics.Process proc = System.Diagnostics.Process.GetCurrentProcess(); | |
proc.Kill(); | |
} | |
protected override void OnFatalException(FatalExceptionEventArgs e) | |
{ | |
throw e.FatalException; | |
} | |
public static bool AttachApp() | |
{ | |
AttachExceptionHandler(new UnhandledExceptionHandlerWithoutUI()); | |
return true; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment