isolatedStorageSettings.ApplicationSettings 不被存储
我试图保留我访问应用程序的最后日期,环顾四周后,我在 App.xaml.cs 中想到了这个 init:
appSettings = IsolatedStorageSettings.ApplicationSettings;
try
{
Debug.WriteLine("INIT LAST MODIFIED " + (string)appSettings["lastModifiedDate"]);
}
catch (KeyNotFoundException)
{
appSettings.Add("lastModifiedDate","");
}
逻辑是,如果尝试显示尚未添加的值(第一次运行),我得到一个异常 KeyNotFoundException。这一切都很好..问题是当我重新启动应用程序时,代码仍然调用异常(就好像未设置变量一样)。如果有人可以回答,我有一些问题:
1)应用程序设置在应用程序关闭后是否仍然存在?(我理解他们会这样做)
2)模拟器是否存储这些值?
如果这些问题中的任何一个都没有问题,那么您是否找出问题所在?
i am trying to retaing the last date that i have visited my app, and after looking around i came up with this init in the App.xaml.cs:
appSettings = IsolatedStorageSettings.ApplicationSettings;
try
{
Debug.WriteLine("INIT LAST MODIFIED " + (string)appSettings["lastModifiedDate"]);
}
catch (KeyNotFoundException)
{
appSettings.Add("lastModifiedDate","");
}
The logic is that if try to display a value that hasn't been added (the first run), i get an exception KeyNotFoundException. This is all good.. The problem is when i restart my application, the code still calls the exception(as if the variable isn't set). A have some questions if anyone could answer:
1) Does the app setting survive after an app close?(i understood they do)
2) Does the simulator store this values or not?
If any of these issues are ok, do you figure out what is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有你需要的线路!
哦 - 是的,模拟器将存储设置,直到您:
每次重新加载模拟器时,它都会重新启动,就像以前从未运行过一样。当您重建项目(不仅仅是构建,而是单击“构建|重建”)时,它会将其从模拟器中删除。它会在实际设备上执行相同的操作。因此,任何时候您想要拥有它,就像您第一次运行应用程序一样,重建,无论是在手机上还是在模拟器上。
There's the line you need!
Oh - and yes, the emulator will store the settings, UNTIL you either:
Every time you reload the emulator, it starts fresh, as if it had never run before. And when you rebuild a project (not just build, but click Build|Rebuild), it will remove it from the emulator. It will do the same on an actual device. So anytime you want to have it so that it is like the first time you run the app, rebuild, whether it is on phone or emulator.