title: Attempt to read or write protected memory. This is often an indication that other memory is corrupt
body: <p>I am creating a CustomMediaTransportControls for MediaPlayerElement. In that I want a button to create a CompactOverlay Frame so I added the below code to <code>public sealed class CustomMediaTransportControls : MediaTransportControls</code>.</p>
  
  <pre><code>public async void CompactOverlayButton_ClickAsync(object sender, RoutedEventArgs e)
  {
      await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =&gt;
      {
          var frame = new Frame();
          compactViewId = ApplicationView.GetForCurrentView().Id;
          frame.Navigate(typeof(VideoPlayerPage));
          Window.Current.Content = frame;
          Window.Current.Activate();
          ApplicationView.GetForCurrentView().Title = "";
      });
      bool viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(compactViewId, ApplicationViewMode.CompactOverlay);
  }
  </code></pre>
  
  <p>But when I use these code I am getting an error message in the XAML part.
  <a href="https://i.stack.imgur.com/EWX2G.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EWX2G.jpg" alt="enter image description here"></a>
  If I didn't use the above function there is no error.</p>
  
  <p><strong>Solution Tried:</strong></p>
  
  <ol>
  <li><p>Running <code>netsh winsock reset</code> in PowerShell</p></li>
  <li><p>Clearing Solution and ReBuilding Solution</p></li>
  </ol>
  
  <p><strong>For Reference:</strong></p>
  
  <p>Here is my entire code</p>
  
  <ol>
  <li><a href="https://www.dropbox.com/s/vwavh26kbycrm5m/CustomMediaTransportControls.cs?dl=0" rel="nofollow noreferrer">CustomMediaTransportControls.cs</a> - <code>ResourceDictionary</code></li>
  <li><a href="https://www.dropbox.com/s/vn5si8bkirqh23h/MediaPlayerDictionary.xaml?dl=0" rel="nofollow noreferrer">MediaPlayerDictionary.xaml</a> - Derived class from <code>MediaTransportControls</code></li>
  <li><a href="https://www.dropbox.com/s/qcawefo710xm9rr/VideosPage.xaml?dl=0" rel="nofollow noreferrer">VideosPage.xaml</a> - Page where <code>CustomMediaTransportControls</code> has been used</li>
  </ol>