I am storing the observable collection in my application isolated storage settings. The list is getting saved successfully during the application exit. But when I launch the application again its not able to find the stored key from the isolated storage.
Here is my code
void LoadSettings()
{
if (settings.Contains("DiaryItems"))
{
diaryItems = (ObservableCollection<MyDiaryItem>)settings["DiaryItems"];
}
}
void SaveSettings()
{
settings["DiaryItems"] = diaryItems;
}
I am calling SaveSettings
method during my application closing and application deactivated.
I am calling LoadSettings
method during my application launching and application activated.
When I was debugging I could see an error saying that
'settings["DiaryItems"]' threw an exception of type
'System.Collections.Generic.KeyNotFoundException'
Just wondering what could be wrong with the settings. The same code works for a simple list of type List.