Skip to content

Console applications

Davide Benvegnù edited this page Feb 27, 2017 · 3 revisions

Console Applications

If you want to add automatic bugs interception on any Unhandled Exception, you need to register a new UnhandledExceptionEventHandler:

static void Main(string[] args)
{
    AppDomain.CurrentDomain.UnhandledException += BugGuardianExceptionTrapper;
    [...]
    //your code here
    [...]
}

static void BugGuardianExceptionTrapper(object sender, UnhandledExceptionEventArgs e)
{
    DBTek.BugGuardian.Factories.ConfigurationFactory.SetConfiguration("http://MY_TFS_SERVER:8080/Tfs", "MY_USERNAME", "MY_PASSWORD", "MY_PROJECT");
    using (var manager = new DBTek.BugGuardian.BugGuardianManager())
    {                
        manager.AddBug(e.ExceptionObject as Exception);
    }
}
Clone this wiki locally