Musings of a PC

Thoughts about Windows, TV and technology in general

Win8 Development: major gotcha in page navigation

One of the major differences in page navigation between Windows Phone 7 and Windows 8 “Modern UI” apps is that the latter allows you to pass an object to the page whereas Windows Phone 7 is pretty much limited to simple items because navigation is done in the form of a URL.

Unfortunately, it turns out that while passing objects to a page does work, it causes a problem with the SuspensionManager because the object cannot be serialized. If you try, the call that SuspensionManager makes to Frame.GetNavigationState() results in an exception.

This took me a while to figure out (mainly because I’d forgotten that I’d been extending my code by passing objects to the pages) but also because I didn’t read the debug output closely enough to see this message:

WinRT information: GetNavigationState doesn’t support serialization of a parameter type which was passed to Frame.Navigate.

So, the upshot is that if you’ve written a Windows Phone app, you can pretty much stick to the same navigation methodology, passing simple objects to the page.

Reference: Microsoft Connect

4 responses to “Win8 Development: major gotcha in page navigation

  1. maythecodebewithyou May 24, 2013 at 3:02 pm

    I’m pretty much stuck in the above mentioned situation. I navigate from my first page to second page and then when i come back and try to terminate the app, it throws a COM exception.

    How do i pass this? or What needs to be done here?

    • Philip Colmer May 24, 2013 at 4:13 pm

      Are you passing an object as a parameter to the navigation code? If you are, you need to use a simple value instead like an int or a string. Objects are not supported.

      • maythecodebewithyou May 25, 2013 at 7:32 am

        Surprisingly I dont use any pass any parameters. I jus use the default navigation. and while terminating the app, the app throws an exception at SaveAsync function()

      • Philip Colmer May 25, 2013 at 8:47 am

        The source to SuspensionManager is included in the project. Have you tried setting a breakpoint on SaveAsync and then stepping through to see where the exception is occurring?

        What sort of exception is being thrown?

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: