ericlee
ericlee

Reputation: 2753

Unable to Save IsolatedStorageSettings.ApplicationSettings for wp7

if (settings.Contains("myDetailsObject"))
    {
        settings["myDetailsObject"] = myDetails;
    }
    else
    {
        settings.Add("myDetailsObject", myDetails);
    }
   settings.Save();

Tried doing the below, however it gave me error. those save values are in strings and is a custom object. tried even saving an integer instead and is still not working

Type 'SharedLibary.Object.MyDetailsObject' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.

Upvotes: 0

Views: 323

Answers (2)

Ku6opr
Ku6opr

Reputation: 8126

Mark class with [DataContractAttribute] attribute and all members that you want to serialize with [DataMemberAttribute]. Note, that marked properties must be public.

Also, don't forget to add reference to System.Runtime.Serialization

Upvotes: 1

Daniel
Daniel

Reputation: 455

Add the attribute [DataMember] on all properties that you want to serialize in your MyDetailsObject class.

Upvotes: 4

Related Questions