[WP Silverlight81]奇怪的ApplicationSettings错误 [英] [WP Silverlight81] Strange ApplicationSettings bug

查看:86
本文介绍了[WP Silverlight81]奇怪的ApplicationSettings错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑以下代码:

   private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
            Debug.WriteLine(IsolatedStorageSettings.ApplicationSettings.Contains("MyKey") ? "TRUE" : "FALSE");
            IsolatedStorageSettings.ApplicationSettings["MyKey"] = DateTimeOffset.Now;
        }   

当你打开,然后手动关闭应用程序(按住按钮以执行此操作)很多次,你会看到输出"FALSE", "TRUE","TRUE"等,这是预期的

When you open, then manually close the app (hold back button to do it) many times, you'll see the output "FALSE", "TRUE", "TRUE", etc, which is expected

现在让我们再添加一行代码:

Now let's add one more line of code:

private void Application_Deactivated(object sender, DeactivatedEventArgs e) { Debug.WriteLine(IsolatedStorageSettings.ApplicationSettings.Contains("MyKey") ? "TRUE" : "FALSE"); IsolatedStorageSettings.ApplicationSettings["MyKey"] = DateTimeOffset.Now; IsolatedStorageSettings.ApplicationSettings["MyAnotherKey"] = DateTimeOffset.Now;

}

在这种情况下,输出将(完全出乎意料)为:FALSE,FALSE,FALSE ..

In this case however the output will (totally unexpectedly) be: FALSE, FALSE, FALSE..

任何想法,这里发生了什么?

Any idea, what is going on here??

推荐答案

Alex Sychev,

Hi Alex Sychev,

我已经在我身边测试了你的代码,我可以得到正确的结果,所以我无法在我的问题中重现你的问题侧。您能否尝试创建一个新的空项目并添加代码以查看它是否有效?尝试在代码中添加断点以查看
发生了什么。此外,我想知道你是否在模拟器和设备中遇到相同的结果。

I have tested your code in my side, I can get the correct result, so I can not reproduce your issue in my side. Could you please try to create a new empty project and add the code to see if it works? Try to add the breakpoint inside the code to see what happens. Besides, I wonder if you meet the same result in the emulator and device.

最好的问候,

Amy Peng

Best Regards,
Amy Peng


这篇关于[WP Silverlight81]奇怪的ApplicationSettings错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆