Bug 45263 - Application.Properties not saving properly this should be fixed
Summary: Application.Properties not saving properly this should be fixed
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-10-11 00:32 UTC by david bagno
Modified: 2017-01-03 21:24 UTC (History)
3 users (show)

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

log file (35.58 KB, text/plain)
2016-10-11 00:32 UTC, david bagno

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:

Description david bagno 2016-10-11 00:32:01 UTC
Created attachment 17973 [details]
log file

Sample code below but works with all properties

if (!Application.Current.Properties.ContainsKey ("HASH")) {
                App.HASH = DependencyService.Get<iKeyChain> ().GetHashCode ().ToString ();
                Application.Current.Properties.Add ("HASH", App.HASH);

            } else {
                App.HASH = (string)Application.Current.Properties ["HASH"];
Comment 1 adrianknight89 2016-10-11 17:46:30 UTC
Can you attach a repro project?
Comment 2 david bagno 2016-10-11 23:58:57 UTC
just paste the below code into any app class to see the bug

 public App ()
            if (!Application.Current.Properties.ContainsKey ("test")) {
                Application.Current.Properties.Add ("test", "test");

            } else {
                var test = (string)Application.Current.Properties ["test"];
            InitializeComponent ();

Comment 3 david bagno 2016-10-12 00:00:28 UTC
I have noticed this bug through the summer I was just to lazy to report on it.
Comment 4 adrianknight89 2016-10-12 03:40:48 UTC
Are you suggesting it doesn't work because it's not saved to persistent storage after the app closes? If that's the case, I could see the bug.
Comment 5 adrianknight89 2016-10-12 04:51:15 UTC
It seems to be working for me on iOS (haven't tested it on Android yet). It doesn't work when you're debugging, but the app deployed on device seems to behave as expected. I put your code after `InitializeComponent();`.
Comment 6 david bagno 2016-10-12 12:00:30 UTC
Yes it is not saving the values to persistent storage.  It use to work though even on the simulator.  Its functionality is well documented and well known.  Please see Charles Petzold's latest book - Creating Mobile Apps with Xamarin.Forms -

This is definitely a bug.  If this feature only works on the device then it is useless.  I have been getting around it by using Jame's CrossSettings plugin but that has a bug on Android.

I hope you guys will try to fix this.
Comment 7 adrianknight89 2016-12-07 19:35:31 UTC
Can you try this in and see if it's working? Lately, I wasn't able to reproduce this while debugging.
Comment 8 Paul DiPietro [MSFT] 2017-01-03 21:24:05 UTC
I am unable to reproduce this with the latest stable release running on an Android 6.0 emulator, nor on an iOS 10.2 emulator. If you are still experiencing this, please upload a reproduction project with the latest release that exhibits the problem, specifying any particular platform or device that has the issue.