Instantly share code, notes, and snippets.

@cdesch /App.cs
Last active Jun 12, 2017

Embed
What would you like to do?
Rollbar.NET WPF Sample
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using RollbarDotNet;
namespace Sample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
System.Diagnostics.Debug.WriteLine("App Start Up");
//Initialize Rollbar
Rollbar.Init(new RollbarConfig
{
AccessToken = "<your rollbar token>",
#if DEBUG
Environment = "development"
#else
Environment = "production"
#endif
});
// Setup Exception Handler
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
Rollbar.Report(args.ExceptionObject as System.Exception);
};
}
}
}
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using RollbarDotNet;
namespace Sample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
System.Diagnostics.Debug.Write("Starting MainWindow");
InitializeComponent();
//Set Default User for RollbarReporting
// -- Reset if user logins in or wait to call SetRollbarReportingUser until user logins in
SetRollbarReportingUser("id", "myEmail@example.com", "default");
}
private void SetRollbarReportingUser(string id, string email, string userName)
{
Person person = new Person(id);
person.Email = email;
person.UserName = userName;
Rollbar.PersonData(() => person);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment