title: Storing objects in IsolatedStorageSettings
body: <p>I have an object I want to store in the IsolatedStorageSettings, which I wan't to reuse when the application restarts.</p>
  
  <p>My problem lies in that the code I have written for some reason does not remember the object when trying to access the key upon restarting it.</p>
  
  <pre><code>namespace MyNameSpace
  {
      public class WindowsPhoneSettings
      {
          private const string SelectedSiteKey = "SelectedSite";
          private IsolatedStorageSettings isolatedStore = IsolatedStorageSettings.ApplicationSettings;
  
          private T RetrieveSetting&lt;T&gt;(string settingKey)
          {
              object settingValue;
              if (isolatedStore.TryGetValue(settingKey, out settingValue))
              {
                  return (T)settingValue;
              }
              return default(T);
          }
  
          public bool AddOrUpdateValue(string Key, Object value)
          {
              bool valueChanged = false;
  
              if (isolatedStore.Contains(Key))
              {
                  if (isolatedStore[Key] != value)
                  {
                      isolatedStore[Key] = value;
                      valueChanged = true;
                  }
              }
              else
              {
                  isolatedStore.Add(Key, value);
                  valueChanged = true;
              }
              return valueChanged;
          }
  
          public MobileSiteDataModel SelectedSite
          {
              get
              {
                  return RetrieveSetting&lt;MobileSiteDataModel&gt;(SelectedSiteKey);
              }
              set
              {
                  AddOrUpdateValue(SelectedSiteKey, value);
                  isolatedStore.Save();
              }
          }
      }
  }
  </code></pre>
  
  <p>I then instantiate WindowsPhoneSettings in App.xaml.cs and make a public getter and setter for it. To be able to access it in the whole application. Debugging this shows that the right object gets stored in the isolated store, but when closing the app and reopening it isolated store seems to be empty. I have tried this on both the emulator and a real device. As you can see I do call the save method when setting the object.</p>
  
  <p>What am I doing wrong here?</p>