System.AccessViolationException was unhandled: Attempted to read or write protected memory

Topics: Windows 8 Xaml
Apr 17, 2012 at 10:44 PM
Edited Apr 17, 2012 at 10:45 PM

Hello,

I'm getting this exception while trying to play a smooth streaming video from winrt/xaml/c#.

The same streaming is being used on wp7 without problems.

System.AccessViolationException was unhandled
  HResult=-2147467261
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=System
  StackTrace:
       at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
       at Microsoft.PlayerFramework.InteractiveViewModel.OnPropertyChanged(String PropertyName)
       at Microsoft.PlayerFramework.InteractiveViewModel.OnPropertyChanged[T](Expression`1 property)
       at Microsoft.PlayerFramework.InteractiveViewModel.<.ctor>b__27(Object s, RoutedPropertyChangedEventArgs`1 e)
       at Microsoft.PlayerFramework.MediaPlayer.OnDurationChanged(RoutedPropertyChangedEventArgs`1 e)
       at Microsoft.PlayerFramework.MediaPlayer.OnDurationChanged(TimeSpan oldValue, TimeSpan newValue)
       at Microsoft.PlayerFramework.MediaPlayer.<.cctor>b__8e(MediaPlayer t, TimeSpan o, TimeSpan n)
       at Microsoft.PlayerFramework.MediaPlayer.<>c__DisplayClass19`1.<RegisterDependencyProperty>b__18(MediaPlayer t, T o, T n)
       at Microsoft.PlayerFramework.MediaPlayer.<>c__DisplayClass10`2.<RegisterDependencyProperty>b__f(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at Windows.UI.Xaml.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Microsoft.PlayerFramework.MediaPlayer.set_Duration(TimeSpan value)
       at Microsoft.PlayerFramework.MediaPlayer.OnNaturalDurationChanged(Duration newValue)
       at Microsoft.PlayerFramework.MediaPlayer.<.cctor>b__a1(MediaPlayer t, Duration o, Duration n)
       at Microsoft.PlayerFramework.MediaPlayer.<>c__DisplayClass19`1.<RegisterDependencyProperty>b__18(MediaPlayer t, T o, T n)
       at Microsoft.PlayerFramework.MediaPlayer.<>c__DisplayClass10`2.<RegisterDependencyProperty>b__f(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at Windows.UI.Xaml.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened()
       at Microsoft.PlayerFramework.MediaPlayer.OnMediaOpened(RoutedEventArgs e)
       at Microsoft.PlayerFramework.MediaPlayer.MediaElement_MediaOpened(Object sender, RoutedEventArgs e)
  InnerException: 

 

I've tried with two different machines with same results.

Any idea? Need more data?

Thanks

Coordinator
Apr 17, 2012 at 11:31 PM


Is this with a live smooth streaming manifest (.isml)? If so, there is a known bug that has been fixed and will be available in the next update. If you want to apply the fix to the source to unblock yourself, here's the change:

In MediaPlayer.cs change...

        void OnNaturalDurationChanged(Duration newValue)
        {
#if SILVERLIGHT
            if (newValue.HasTimeSpan)
            {
                Duration = newValue.TimeSpan;
            }
#else
            Duration = newValue.TimeSpan;
#endif

        }

to this...

            if (newValue.HasTimeSpan && newValue >= TimeSpan.Zero)
            {
                Duration = newValue.TimeSpan;
            }

Sorry for the inconvenience, our next update should be available soon (next week or so).

Apr 18, 2012 at 5:15 PM

It worked!

Thanks

Apr 20, 2012 at 2:19 PM

 

Hi,

 

I've made the change build the project and add reference on my project to the new assembly.

When i build my project i receive the following error:

Error 5 Payload file '\Microsoft.PlayerFramework.Source.2012_03_09_00\Metro.Xaml\bin\Release\Microsoft.Metro.PlayerFramework.Xaml\Themes\generic.xaml' does not exist.

 

Can you help me ?

Apr 20, 2012 at 2:23 PM

Instead of just adding the reference, i included the Microsoft.Metro.PlayerFramework.Xaml to my solution and it works fine.

Apr 20, 2012 at 2:45 PM

Yup i've done the same and it worked :)

 

By the way if i want to have a video running on fullscreen on windows 8, do you know what has to be done ?

 

Regards

Coordinator
Apr 20, 2012 at 6:46 PM

raulribeiro, binaries in Win8 are a little different from SL or WPF assemblies in that generic.xaml is a loose resource file and needs to be included along with the dll and kept in its respective relative path. Here's a great blog post by Tim Heuer on creating redistributable components for Win8. Find the section: Package your control as an Extension SDK for more details on the anatomy of what needs to be redistributed.

Regarding full-screen, in Xaml, just put the MediaPlayer object in the LayoutRoot grid on your page and it will automatically consume the size of it's container (which is full screen by default). Set a height/width or reduce the size of the container to make it non-full screen.