Program crashes when hangs in Windows Store App

Source: Internet
Author: User

When I developed the Windows Phone 8.1 program yesterday, I found that the program automatically exited when it was suspended. Debug found error message Yes

System.Runtime.InteropServices.COMException (0x80004005): Unspecified errorgetnavigationstate doesn  'T support serialization of a parameter type which is passed to Frame.navigate. At    Windows.UI.Xaml.Controls.Frame.GetNavigationState () at   TX. WifiSurfing.Common.SuspensionManager.SaveFrameNavigationState (frame frame) at   TX. WifiSurfing.Common.SuspensionManager. <SaveAsync>d__0.movenext () System.Collections.ListDictionaryInternal

This means that because the parameters of the page navigation do not support serialization, there is an exception when the program hangs when the state is saved:

       /// <summary>        ///called when the application execution will be suspended. The application state will be saved///will be terminated or resumed with the application state saved,///and keep the contents of the memory intact. /// </summary>        Private Async voidOnsuspending (Objectsender, Suspendingeventargs e) {            varDeferral =e.suspendingoperation.getdeferral (); await Suspensionmanager.saveasync ();        Deferral.complete (); }

But my entire program didn't pass the object when I was navigating, and the problem was confusing to me. By looking at the Onnavigatedto method of the exception page, I find that when I use navigatetopageaction navigation, if parameter is not set, the program sets a default value, Since I triggered the tapped event using Eventtriggerbehavior, the parameter is set to Tappedroutedeventargs, which is an object that is not serializable, so there was an error while saving the state when it was suspended. Set it to Parameter= "" is a solution (note: set to Parameter= "" and parameter= "{x:null}" neither, or the original default value).

Suspensionmanagererrordemo.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.