IsolatedStorageSettings.ApplicationSettings doesn't get stored to restart - windows-phone-7

I'm writing a WP7 (Mango) application.
I store values in WP7 IsolatedStorageSettings.ApplicationSettings, then I call IsolatedStorageSettings.ApplicationSettings.Save();
If I press back, and leave the screen, and I come back I can read values just fine.
However if I press restart in the debugger (or just restart from the emulator) the ApplicationSettings throws a KeyNotFoundException, as if it didn't persist...
I haven't yet tried it on device, I don't have one available right now.
What can I possibly be doing wrong?

It turns out the problem wasn't in the emulator AT ALL, so everyone suggesting this is "by design" in emulator turned out to be wrong (but I can't undo my upvotes as they are locked).
The problem was that I tried to persisting a non-serializable class, and wp7 handled this by throwing away ALL my settings at next Save(). When I removed that single Add() (or more precisely serialzied that object with JSON.net (which COULD handle it), and persisted the json string) all my problems simply went away.
Still, ridiculous behavior on wp7's part.

This behavior is "by design" on emulator.
I suggest, below steps for your code.
1. Check Key is available or not
2. If not, then set default value to it.

Check that question: Automatic login process in Windows Phone 7.1 application
On emulator IsolatedStorage is not persistent after reload and that's for both files and application settings.
You can use Isolated Storage Explorer Tool from wp7 sdk to take a snapshot of isolated storage content and restore it after the restart: Click
That problem doesn't occur on real device where Isolated Storage is persistent.

I got the same error(The error occurs because after you stop the debugger the key get deleted), and I posted a question regards this: Automatic login process in Windows Phone 7.1 application. suggest you to use site settings instead of application settings. One more option:http://www.codeguru.com/csharp/.net/wp7/article.php/c19215/Using-Isolated-Storage-for-your-Windows-Phone-7-WP7-App.htm. Hope it solves your problem.

Related

Blazor app requires server restart every change I make

I'm developing on my localhost a new Blazor server-hosted app. I launch the template that it starts you out on... looks very nice. I change the text in the tag, refresh my browser... and no change. I refresh and refresh only to notice no change. Is something wrong?
Then I rebuild and rerun the app again and the change happened. Why do I have to restart the entire server for a small front-end change? I have to do this on every change I make? Even though the changes are for the front-end? If so, then the development experience for MVC apps is way better. I don't have to restart my server for changing the code for the front end.
I know dotnet watch exists, but it doesn't help. It still restarts the server for every change I make for the front-end. I have to wait like 10 seconds for just changing some CSS? Please tell me if I'm doing something wrong, or if this is by design.
Also, I tried the web-assembly version of Blazor. Same results.
I guess you are running the app with the debugger connected? this prevents the recompilation. You need to:
Press Ctrl-F5 to run the app without the debugger.
This should work on Windows using IIS, but on Mac "it's a bit more complex". According to a MSFT representative, they are planning on enabling this functionality for Mac users, but this info is already over a year old (from April 2020).
This issue still happens, and for me is a major downside. It doesn't make any sense to have to recompile entire project just because I changed some text on a page. If this is a design choice, it's doomed! Can't have a designer dependent on developers to recompile whenever a small change is required on simple html! Even if you change an element style you have to recompile!

App crashes when being resumed

My wp7 app crashes when I come back from a task such as Map, Call or Web Browser. Infact, if i lock my phone and resume it again, still it crashes. Please tell me what could be the problem and how can I remove it?
There is a problem with you code.
Remove the application off the phone by starting a new emulator instance.
Open App.xaml.cs
Put a breakpoint in the method RootFrame_NavigationFailed and Application_UnhandledException
Now use the CallStack to find the root of the issue.
With no code posted (and in your case it could be ANYTHING in the project) you will be the best person to resolve your issue. If you can post a small reproduction on here we can take a look.
In application exit methods you probably should restore the data you dealt with last time before you quited

Silverlight and Windows 8 Consumer Preview working?

The Windows 8 Consumer Preview is now available. It is known that Silverlight will not run in metrostylemode, but with legacy/desktopmode it is working?
Anything unusual to keep in mind?
Are you able to access Silverlight applications?
(sorry for my bad english)
I have an medium sized SL5 LOB RIA Services app that runs OOB and it is working fine on windows 8 CP. The only thing that did not worked as I expected is that the on-screen keyboard do not show when I enter a text field. probably there is a way to p/invoke this but it would be nice if this happens by default.
I don't think there was anything new posted to that effect (but then the story was already explained in Dev Preview). It basically works the way you describe in Beta.
Apparently you can add a meta tag which causes the metro browser to prompt the user, but I have not yet tested.
Check out the following link:-
http://www.winmatrix.com/forums/index.php?/topic/33701-plug-in-free-web-in-ie10-metro/

WP7: Edit Screenshot While App is Backgrounding (Mango)

I have an app that I have been developing that can display sensitive user data.
When the user backgrounds the app, the OS appears to take a screenshot of the app as it was running, and displays it so when the user returns, their state is restored.
I am trying to prevent the user's information from being seen in this screenshot.
My initial idea was to display a Popup of my splash screen image, but it does not seem to render it in ApplicationDeactivated. Is there any other way you might accomplish this?
I am not sure you are analyzing this correctly. I don't see how the OS could take a screenshot of an app and use that to restore state. Also, if it was true that the OS did that, Tomb Stoning wouldn't be such a big issue in the requirements for an app in the submission process. A dev needs to handle grabbing and saving state on exit and reloading it on start-up again.
If you didn't code this tomb stoning, are you using a frameowrk that has built in support for this? You could disable the tombstoning so certain pieces of information are not stored, and in fact if this data is that sensitive you should make sure it isn't saved. But, if you save it make sure you encrypt it so nothing else could examine the saved state. Although, that shouldn't be possible on Win Phone as the OS is supposed to enforce the boundries between apps.
Received a response from Microsoft which indicates that this is not possible in the Mango SDK; it may be added into future releases of the platform.

WP7 app won't launch from app list

I have a simple Windows Phone 7 application which is working perfectly when started from Visual Studio. However, if I deactivate the app (press Windows button or back button from the application's MainPage) and then click the app's icon to relaunch, the screen will flash and return to the list/home screen. I assumed this was an issue with the emulator but when I got a developer device I have the same issue.
Note that reactivating without a complete tombstone works (pressing Windows button from the app and then back).
I have no idea what causes this or how to proceed with debugging. Hopefully someone else has experienced this and knows a fix.
Turns out there is a bug, i found the solution here http://forums.create.msdn.com/forums/p/67522/416995.aspx
In short, it turns out that the Microsoft.Xna.Framework.Media.MediaLibrary class (which I am using to display pictures on applications main page) is not properly initialized when the user has not opened a media hub prior to you calling it. So picture collection properties are null or empty. The solution is to add a call to MediaPlayer.Queue.ToString(), it will force the initialization of the native media library allowing you to invoke the MediaLibrary later on.
Sounds like an unhandled error on startup is causing the app to crash.
Trap/log/handle/display any unhandled exceptions. Also check what you're doing on startup.
IF you are saving something (to Isolated Storage) after first run and then opening it on subsequent launches then that's where I'd look first.
If it works when launched from Visual Studio then this will probably be due to the way you are rebuilding/redeploying the app before launching it in that case.

Resources