famer
famer

Reputation: 499

Isolated Storage(IsolatedStorageSettings) limitations on windows phone

I have key-value IsolatedStorage in my app, it contain 4 vars: 2 doubles, 1 bool and 1 ObservableCollection of classes objects. When I set ObservableCollection to settings and save it like this

settings["PlaceMarks"] = PlaceMarks;

it overwrites my bool var and on next start I got "key not found" exception

if I write to this settings something like string or number

settings["PlaceMarks"] = "string";

All is ok. My collection have only three instance of simple classes. So here is my question why my value disappears? May be it some limitations of IsolatedStorageSettings I didn't know

Upvotes: 2

Views: 520

Answers (2)

Pedro Lamas
Pedro Lamas

Reputation: 7233

Only serializable objects (not the case of ObservableCollection) can be saved in the IsolatedStorageSettings.

Objects are serialized using the DataContractSerializer before saving the IsolatedStorageSettings.

https://stackoverflow.com/a/7417049/358596

Upvotes: 1

Hermit Dave
Hermit Dave

Reputation: 3046

have you marked those classes that are in Observeable Collection as Serializeable ?

ObservableCollection itself is not marked as serializeable. http://msdn.microsoft.com/en-us/library/ms668604(v=vs.95).aspx

I would suggest you try using a List instead

Upvotes: 3

Related Questions