title: Using Application.Current.Properties to cache data is throwing error in Xamarin.forms
body: <p>I am developing a xamarin forms application. First of all, I am a newbie to xamarin and just started it today. But I am an experienced Android Developer. What I am trying to do now is I want to store local data of my application like SharedPreference in Android. So, the application will remember the data when the user reopens the app. I found those links that suggesting to use Application.Current.Properties - <a href="https://forums.xamarin.com/discussion/106505/basic-local-storage-how-to" rel="nofollow noreferrer">https://forums.xamarin.com/discussion/106505/basic-local-storage-how-to</a> and <a href="https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/application-class/" rel="nofollow noreferrer">https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/application-class/</a>. I tried it. But it is not working. </p>
  
  <p>This is my testing code.</p>
  
  <pre><code> public ItemDetailPage()
      {
          InitializeComponent();
  
          setLabelValue();
          Application.Current.Properties["testing"] = "this is label restored from the local storage.";
          Application.Current.SavePropertiesAsync();
      }
  
      private void setLabelValue()
      {
          counter = 1;
          string testing = "this is default label";
          if(Application.Current.Properties.ContainsKey("testing"))
          {
              testing = Application.Current.Properties["testing"].ToString();
          }
          this.FindByName&lt;Label&gt;("labelTest").Text = testing;
  
      } 
  </code></pre>
  
  <p>According to the code above, when I access that page for the first time it should set the label value as "this is default label". But for the consequent access, the label value should be "this is label restored form the local storage". When I access the page for the second time, it is giving me this error.
  <a href="https://i.stack.imgur.com/cJazF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cJazF.png" alt="enter image description here"></a></p>