1
votes

So basically I have 2 projects, 1 my project and the 2nd a scheduledagent.

In the scheduledAgent I make a server call (my app gets deactivated) and I want to save the reply into isolatedstorage, after which my app gets reactived.

So after my app gets reactivated I want to load the value that I saved in the scheduledAgent, but the problem is it is null everytime. (I am calling the save method)

code for scheduledagent:

so inside the OnInvoke method:

 IsolatedStorageSettings.ApplicationSettings.Remove("token");
 IsolatedStorageSettings.ApplicationSettings.Add("token", grant_token);
 IsolatedStorageSettings.ApplicationSettings.Save();

(App gets reactivated)

code which continues to read the saved info:

 IsolatedStorageSettings.ApplicationSettings.TryGetValue("token", out reply);

The problem is that "reply" is always empty, and grant_token does contain a value when saving

any feedback will help

thanx! B

2
I think the values are loaded the first time you call IsolatedStorageSettings.ApplicationSettings, and kept in memory. So even if you call Save you won't have the new values, as they won't be read again. As a workaround, I suggest you manually save/read the values from the isolated storage, rather than using IsolatedStorageSettings.ApplicationSettings - Kevin Gosse

2 Answers

0
votes

Is your scheduled agent exiting correctly? IsolatedStorageSettings won't save if it doesn't.

0
votes

I developed a quick and easy Isolated Storage DLL that is free to use and allows you to save anything that inherits from Object (so basically everything). If you have anymore issues I would give it a try it's pretty simple.

Object whatEverYouWantToSave = new Object();

EZ_Iso.IsolatedStorageAccess.SaveFile("MyFileName",whatEverYouWantToSave ):

That's it! It serializes it to the isolated storage for you. No mess.

You can download it at http://www.anthonyrussell.info/postpage.php?name=47