I'm currently using AudioPlaybackAgent
to play online audio stream (mp3
). If device is connected to the internet audio is playing. But when there is no network connection and I press the play
button in my app, crashes with
An unhandled exception of type 'System.SystemException' occurred in System.Windows.ni.dll
And it points me to this part of code
....
case UserAction.Play:
if (player.PlayerState != PlayState.Playing)
{
player.Play();
}
break; // << right here
....
I can paste my whole Audio Player but its standard generated background audio player. What is also wired here is that on background player initialization there is line of code
Application.Current.UnhandledException += AudioPlayer_UnhandledException;
which should handle unhandled exceptions...but it don't.
I can catch this exception inside audio player using simple try-catch but I can't display it using MessageBox right from audioplaybackagent (because MS is not allowing it if you try to submit app to store).
So my questions here are:
- How can i capture exception inside my app and then show for example MessageBox to user saying that there is no network connection
- Why is unhandled exception not handled by piece of code posted?
Thanks for your help!