Bug 27149 - Application.Current.Properties wipes if you store anything but primitives on WindowsPhone
Summary: Application.Current.Properties wipes if you store anything but primitives on ...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.3
Hardware: PC Windows
: Normal enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-17 11:53 UTC by andreas.jacobsen
Modified: 2016-04-08 19:24 UTC (History)
8 users (show)

Tags: U7K application
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description andreas.jacobsen 2015-02-17 11:53:31 UTC
Hi!

If you have a Xamarin.Forms project, and you try to persist data with the Application.Current.Properties dictionary (<string, object>), and you store an object insted of a primitive data type, the dictionary will not persist after rebooting.

Steps for recreating:

1. Create new Xamarin.Forms project
2. Create your Main Page.
3. Insert an object - could be any object, in the dictionary.
4. Reboot app - dictionary is now empty.
Comment 1 andreas.jacobsen 2015-02-17 11:54:51 UTC
NOTE: This is for WindowsPhone only.
Comment 2 Rui Marinho 2015-05-21 20:39:18 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue we would very much appreciate it. We monitor recently touched NEEDS INFO bugs so we’ll notice you attached the reproduction we’ll take it from there. 

Warm regards,
Xamarin Forms Team
Comment 3 John Hardman 2015-06-10 12:39:58 UTC
I have hit the same problem when saving Color values.

What appears to be happening is that when writing to storage, it is doing a ToString() on the object being passed. If you cannot cast from a string back to that type of object, then you get a System.FormatException when trying to re-create your object.

From the documentation, it would appear that it should be able to store any type of object, presumably using reflection to do so. Using ToString() is not what I expected, and sure breaks my initial attempt at loading Color values.
Comment 4 John Hardman 2015-06-10 12:40:32 UTC
I should have mentioned, I am using 1.4.3.6358-pre2
Comment 5 Jason Smith [MSFT] 2016-04-08 19:24:50 UTC
We are adding the ability to specify serializers for the properties so you can extend its capacities. Thank you for taking the time to submit this feature request. We like this idea and have added it to our internal feature tracking system.

Warm regards,
Xamarin Forms Team