Ive added BugSense to my Windows Phone app and modified the app.xaml.cs accordingly. However, I know some users are experiencing crashes but BugSense is not seeing it. BugSense to see new sessions and what not so i know the license is correct.
I believe the crashing occurs within this code, particularly with webclient I think. What do can I add to this code so that if something occurs, BugSense will report it?
private void LongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
LongListSelector selector = sender as LongListSelector;
// verifying our sender is actually a LongListSelector
if (selector == null)
return;
SoundData data = selector.SelectedItem as SoundData;
// verifying our sender is actually SoundData
if (data == null)
return;
if (data.IsDownloaded)
{
this.PlaySound(IsolatedStorageFile.GetUserStoreForApplication().OpenFile(data.SavePath, FileMode.Open, FileAccess.Read, FileShare.Read));
}
else
{
if (!SimpleIoc.Default.GetInstance<INetworkService>().IsConnectionAvailable)
{
MessageBox.Show("You need an internet connection to download this sound.");
}
else
{
WebClient client = new WebClient();
client.DownloadProgressChanged += (senderClient, args) =>
{
Dispatcher.BeginInvoke(() =>
{
data.DownloadProgress = args.ProgressPercentage;
});
};
client.OpenReadCompleted += (senderClient, args) =>
{
using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(data.SavePath))
{
args.Result.Seek(0, SeekOrigin.Begin);
args.Result.CopyTo(fileStream);
this.PlaySound(fileStream);
data.Status = DownloadStatus.Downloaded;
}
args.Result.Close();
};
client.OpenReadAsync(new Uri(data.FilePath));
data.Status = DownloadStatus.Downloading;
}
}
selector.SelectedItem = null;
}
I've just started using BugSense myself in my WP8 app and I've very impressed how it catches unhandled exceptions without anything more than the single line of code in my App.xaml.cs file:
So from my experience BugSense should be catching these exceptions for you without any extra code on your part.
How do you know about these crashes? Is it from the Windows Phone Dev Center? If so then you might still be seeing crashes reported from users that have an older version of your app installed before you added BugSense.
I find that checking for a new app version from within the app itself on start-up and alerting the user is a great was to keep people up-to-date. Many users might not visit the Windows Phone Store for extended periods of time and even then may not bother to update your app to the latest version so there's a good chance you have a lot of users on old versions.