我在我的应用程序中遇到了一个非常神秘的错误。我唯一的想法是我试图将太多信息保存到状态中。这篇文章的底部是错误消息。我想知道是否有一种好的方法来管理您保存到状态的数据量。我现在正在使用状态管理器来快速保存数据,但我显然需要向其中添加更多逻辑,即如果 Size > X,则保存到 Isolated 而不是 State。
这方面的最佳做法是什么?
错误:0x80040204
at Microsoft.Phone.Shell.Interop.ShellPageManager.SetProperty(String name, Byte[] blob)
at Microsoft.Phone.Shell.StreamPersister.Save(ShellPageManager shellPageManager, String key, IDictionary`2 dictionary, IEnumerable`1 knownTypes)
at Microsoft.Phone.Shell.PhoneApplicationService.FireDeactivated()
at Microsoft.Phone.Execution.NativeEmInterop.FireOnPause()
最佳答案
查看doc
You should not use this property for excessive storage because there is a limit of 2 MB for each page and 4 MB for the entire application.
首先,我会重新考虑设计。你平均节省多少钱?最大值是多少?让用户长时间等待加载是糟糕的用户体验。如果您真的需要这个,请考虑仅使用 IsolatedStorageFile 而不要使用“如果 Size > X,则保存到 Isolated 而不是 State。”
关于c# - Windows Phone 上的状态大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9998090/