c#-GetNavigationState不支持传递给Frame.Navigate的参数类型的序列化

我将WinRT和Prism用于Surface App.在暂停时获取此异常.GetNavigationState不支持传递给Frame.Navigate的参数类型的序列化.

解决方法:

很可能是您在某个地方将复杂类型传递给Navigate(),而该类型无法序列化.

正如Luis Cantero here回答的那样:

To enable serialization of the frame’s state using GetNavigationState,
you must pass only basic types to this method, such as string, char,
numeric, and GUID types. If you pass an object as a parameter, an
entry in the frame’s navigation stack holds a reference on the object
until the frame is released or that entry is released upon a new
navigation that diverges from the stack. In general, we discourage
passing a non-basic type as a parameter to Navigate because it can’t
be serialized when the application is suspended, and can consume more
memory because a reference is held by the frame’s navigation stack to
allow the application to go forward and back.

另请参见Exception when calling SuspensionManager.SaveAsync()

http://www.damirscorner.com/UsingSuspensionManagerForSavingApplicationState.aspx

上一篇:在WPF中,如何使用DataGridTemplateColumn绑定用户控件失败


下一篇:c#-在画布中放置对象