Exception handling for Windows Store apps couldn’t be easier! Using the Raygun4Net NuGet package, you can set up your Windows Store application to report all unhandled exceptions (and even handled ones if you like) to Raygun, where you can learn what exceptions are causing your application to crash.
Adding Raygun to your Windows Store App
The first thing you need to do is install the
Mindscape.Raygun4Net package. You can do this through the NuGet Package Explorer, or through the Package Manager Console by running
Once this is installed, you need to attach the RaygunClient to your Application. This is easy – just add this code to your App’s constructor
You will need your Raygun Application’s API Key for this – you can find it in the Application Settings in Raygun.
This will set up Raygun to catch all unhandled exceptions. I told you it was easy! But wait, there’s more!
If your app knows who is logged in, you can attach that user’s information to the exception reported to Raygun. Maybe all of your crashes are coming from one user with bad hardware, or a low end device. Raygun’s User Tracking feature lets you see this information alongside the exception.
When you know what user is using your app, simply set the
UserInfo property on the
RaygunClient.Current object with as much information as you have.
RaygunClient.Current.UserInfo = new RaygunIdentifierMessage("email@example.com")
Email = "firstname.lastname@example.org",
FirstName = "Jamie",
FullName = "Jamie From Raygun",
UUID = AdvertisingManager.AdvertisingId
AdvertisingId might be empty if the user has turned off the Advertising Id in their Windows Privacy settings. That makes it a poor candidate for the Identifier (the
RaygunIdentifierMessage constructor parameter is a unique identifier for the user).
Grab your Raygun trial
Want awesome error handling for Windows? Dive in and hook up Raygun in your Windows Store apps now! If you need a Raygun account, as always there’s the free trial available here.