0

I keep getting the following error, and I don't understand why. It happens on suspend, but only after visiting a page twice. That is to say, the app loads up and I go to the page, then use VS2013 to suspend the app and it works just fine. However, if I instead open the app, go to the page, then go back and go to the page again, then suspend... I get the error. I am not passing any complex types to frame.Navigate, nor even any primitive types. I've changed my app to ensure it doesn't even use navigation parameters anymore, in an effort to fix this issue. Meanwhile, since I'm using MVVM via Prism, I never call frame.Navigate directly anyways. I believe something with the SessionStateService calls it, but I can't debug through there to figure out what's going on.

Error: "GetNavigationState doesn't support serialization of a parameter type which was passed to Frame.Navigate."

The only weird thing I'm doing is that I am embedding a UserControl on my page and I have the viewmodel for it in my page viewmodel. However, the embedded control's viewmodel is not a Prism.StoreApps.Viewmodel, it is just implementing INotifyPropertyChanged. This is because I use this user control in 2 pages, rather than it being it's own page. Is this causing the issue? The user control's viewmodel is a property on each page's viewmodel class, and the property is marked as [RestorableState], as are the properties within that user control's viewmodel. If you think this could be causing it, please let me know the proper way to embed a user control MVVM style for prism.

Note, I also setup an override for OnRegisterKnownTypesForSerialization and called SessionStateService.RegisterKnownType for my user control's viewmodel.

TonyE
  • 113
  • 1
  • 8

1 Answers1

1

I was able to add the Microsoft.Practices.Prism.StoreApps project from the MS example code to my solution rather than referencing the dll from NuGet. This allowed me to debug. As best I can tell the problem is that the frame's BackStack contains a past navigation record with a complex object. In this case it turned out to be a RoutedEventArgs object, which was there by default because I was using the Core.NavigateToPageAction event trigger behavior with no parameter specified. Apparently if you don't specify a parameter, it passes a RoutedEventArgs object with the button that was clicked.. As soon as I set the parameter to "wow", it stopped having the error.

The lame part is that this was on a back button, so there is no intended parameter :( Anyway, this fixed my problem.

TonyE
  • 113
  • 1
  • 8