Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

Topics: Windows 8 Xaml
Apr 18, 2013 at 6:53 AM
I have next/prev button on my app. I set new mediaPlayer.source when user clicks next. If I click next repeatedly then at some point app crashes with Catastrophic failure. I don't see call stack so don't know what exactly causing crash. Is there slomething I should check before settings new source?

A first chance exception of type 'System.Exception' occurred in Microsoft.PlayerFramework.DLL

Additional information: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Apr 19, 2013 at 9:45 AM
call stack:
Microsoft.PlayerFramework.DLL!Microsoft.PlayerFramework.MediaPlayer._AudioStreamIndex.get() + 0x6e bytes
Microsoft.PlayerFramework.DLL!Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened() + 0x2d9 bytes
Microsoft.PlayerFramework.DLL!Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened.MoveNext() + 0x6a bytes
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened>(ref Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened stateMachine) + 0x47 bytes
mscorlib.dll!System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start<Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened>(ref Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened stateMachine) + 0xf bytes
Microsoft.PlayerFramework.DLL!Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened(Windows.UI.Xaml.RoutedEventArgs e = {Windows.UI.Xaml.RoutedEventArgs}) + 0x89 bytes   
Microsoft.PlayerFramework.DLL!Microsoft.PlayerFramework.MediaPlayer.MediaElement_MediaOpened(object sender = {Windows.UI.Xaml.Controls.MediaElement}, Windows.UI.Xaml.RoutedEventArgs e = {Windows.UI.Xaml.RoutedEventArgs}) + 0x25 bytes   
[Native to Managed Transition]  
Sep 5, 2013 at 12:41 PM
From what I can tell, there an error when a SetValue is executed inside the OnMediaOpened() method (specifically, when trying to set the AudioStreamIndex depenency property. While I don't see how to fix the issue(since we can't access the _AudioStreamIndex), I found out to at least circumvent the crash. Infact that crash is caused by an impropely made async void method. Async void WILL crash your app if there's any exception raised (see ).

To circumvent this issue(until fixed), create an class that inherit the MediaPlayer class and override the OnMediaOpened method (it's virtual, hurray) with the following:
protected override void OnMediaOpenend()
   Catch(Excepion ex)
       //Do your exception handling here... at least log it.