Problem with using Application.Current.Properties. Cannot access to Dictionary.

Stfn11Stfn11 PLMember

This is how I use it:

public partial class ConfigurationPage : ContentPage
    {
        public const string storageLinesSelectors = "configurationLinesSelectorsJson";

        public ConfigurationPage()
        {
            InitializeComponent();
            RestoreData();
        }

        private void RestoreData()
        {
            try { 
                IDictionary<string,object> properties =Application.Current.Properties;
                if (properties.ContainsKey(storageLinesSelectors))
                {
                    var selectors = Application.Current.Properties[storageLinesSelectors] as string;
                    SaveConfigureLines(JsonConvert.DeserializeObject<List<string>>(selectors));
                    LoadedPreviousStateMessage.IsVisible = true;
                }
            }
            catch(AggregateException aex)
            {
                foreach (Exception ex in aex.InnerExceptions)
                {
                    Debug.WriteLine(ex.Message);
                }
                Debug.WriteLine("End of AggregateException");
            }
        }
[...]
  }

The exact error which I get is System.AggregateException. This is what "try/catch" writes in debug console:

Error in line 1 position 206. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:Value' contains data of the 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:ArrayOfstring' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'ArrayOfstring' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.

I was following this tutorial and I've done everything exactly the way they recommended. Despite that, I see above-mentioned error. What do you think caused this and how can I fix it?

I use Xamarin Forms 2.2.0.43. Application is being tested on Windows 10 Desktop.

Answers

  • X-ArielX-Ariel ARMember ✭✭

    Same issue at "UWP" (Xamarin.Froms 2.3.3.180). When i get fix it, i will writ.

Sign In or Register to comment.