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