8

Currently i am using the following method to store the data which compiles successfully

App.removalList.Add(new RemoveFavourites(App.user.auth_token, App.user.user_id, proid.ToString()));

ApplicationData.Current.LocalSettings.Values["Remove_fav_properties_list"] = App.removalList;

It compiles successfully however i am getting the following error at runtime:

WinRT information: Error trying to serialize the value to be written to the application data store.
Additional information: Data of this type is not supported.

Following is the RemoveFavourites Class:

public class RemoveFavourites
{

    public string auth_token { get; set; }

    public string user_id { get; set; }

    public string property_id { get; set; }

    public RemoveFavourites(string auth_token, string user_id, string property_id)
    {
        this.auth_token = auth_token;
        this.user_id = user_id;
        this.property_id = property_id;
    }
}

and the complete exception is

An exception of type 'System.Exception' occurred in mscorlib.ni.dll but was not handled in user code WinRT information: Error trying to serialize the value to be written to the application data store Additional information: Data of this type is not supported. Error trying to serialize the value to be written to the application data store If there is a handler for this exception, the program may be safely continued.

Hamid Pourjam
  • 20,441
  • 9
  • 58
  • 74
Bilal Amjad
  • 232
  • 2
  • 13

1 Answers1

4

You can not store complex objects in app settings. (reference)

Try to serialize the object (maybe using json or custom way of serializing you have implemented yourself) and then store the data.

Hamid Pourjam
  • 20,441
  • 9
  • 58
  • 74
  • Are you totally sure that it is impossible or is ist just impossible to configure in the IDE of Visual Studio? – Codor Dec 16 '15 at 10:12
  • see the reference @Codor – Hamid Pourjam Dec 16 '15 at 10:13
  • 1
    Thanks for the hint; note that [this answer](http://stackoverflow.com/questions/8688724/how-to-store-a-list-of-objects-in-application-settings) suggests using custom formatting to store objects of user-defined types (which could be considered as 'shoe-horning' one mechanism into another). – Codor Dec 16 '15 at 10:14