模拟器上的隔离存储总是空的?
在我的 WP7 应用程序中,我正在做:
string userName = IsolatedStorageSettings.ApplicationSettings.Contains("UserName") ? IsolatedStorageSettings.ApplicationSettings["UserName"].ToString() : null;
if (string.IsNullOrEmpty(userName))
IsolatedStorageSettings.ApplicationSettings["UserName"] = "test";
我启动我的应用程序(F5),当然,用户名是空的,因此它存储在独立存储中。
我停止我的应用程序(停止调试),并且我不关闭模拟器
再次启动我的应用程序(F5),但仍然为空。
我读到,当模拟器未关闭时,隔离存储应该持续存在。
我做错了什么?
预先感谢您的回答。
in my WP7 application, I'm doing :
string userName = IsolatedStorageSettings.ApplicationSettings.Contains("UserName") ? IsolatedStorageSettings.ApplicationSettings["UserName"].ToString() : null;
if (string.IsNullOrEmpty(userName))
IsolatedStorageSettings.ApplicationSettings["UserName"] = "test";
I launch my app (F5), off course, the userName is empty, so it's stored in isolated storage.
I stop my app (stop debugging), and I don't close emulator
Launch again my app (F5), but still empty .
I've read that the isolated storage should persist while the emulator isn't closed.
What am I doing wrong ?
Thanks in advance for your answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还需要致电。
更改设置后
You need to also call
after you've changed the settings.
您是否尝试过正常退出应用程序? (通过按模拟器中的后退按钮,而不是按 Visual Studio 中的“停止”按钮)。我认为IsolatedStorageSettings.ApplicationSettings的内容在应用程序退出时保存。 Visual Studio“停止”按钮会终止应用程序,从而阻止保存代码运行。
Have you tried exiting the app normally? (by pressing the back button in the emulator, not by pressing the 'stop' button in Visual Studio). I think the content of IsolatedStorageSettings.ApplicationSettings is saved when the application exits. The Visual Studio 'stop' button kills the app, therefore preventing the saving code from running.