Bug 53840 - Xamarin.Forms PropertyStore: Exception while reading Application properties: System.Runtime.Serialization.SerializationException
Summary: Xamarin.Forms PropertyStore: Exception while reading Application properties: ...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-03-23 10:34 UTC by Alessandro
Modified: 2017-06-20 18:28 UTC (History)
3 users (show)

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


Attachments
sample project (293.08 KB, application/x-zip-compressed)
2017-03-23 18:21 UTC, Jimmy [MSFT]
Details


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 NOT_REPRODUCIBLE

Description Alessandro 2017-03-23 10:34:24 UTC
I have this exception in Android app 
when I execute this: Application.Current.Properties.ContainsKey("PathFileConfig")

Xamarin.Forms PropertyStore: Exception while reading Application properties: System.Runtime.Serialization.SerializationException: 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.
  at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize (System.Runtime.Serialization.XmlReaderDelegator reader, System.String name, System.String ns, System.Type declaredType, System.Runtime.Serialization.DataContract& dataContract) [0x00087] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs:192 
  at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Int32 id, System.RuntimeTypeHandle declaredTypeHandle, System.String name, System.String ns) [0x00009] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs:131 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.InternalDeserialize (System.Type type, System.String name, System.String ns) [0x00017] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:352 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadValue (System.Type type, System.String name, System.String ns) [0x00215] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:344 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadMembers (System.Int32 index, System.Runtime.Serialization.ClassDataContract classContract, System.Boolean[] requiredMembers, System.Int32& memberIndex, System.Int32& requiredIndex) [0x000cf] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:256 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadMembers (System.Runtime.Serialization.ClassDataContract classContract, System.Runtime.Serialization.ExtensionDataObject extensionData) [0x00093] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:225 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadClass (System.Runtime.Serialization.ClassDataContract classContract) [0x0005c] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:202 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadFromXml (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Runtime.Serialization.XmlObjectSerializerReadContext context, System.Xml.XmlDictionaryString[] memberNames, System.Xml.XmlDictionaryString[] memberNamespaces) [0x0007c] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:81 
  at System.Runtime.Serialization.XmlFormatReaderGenerator+CriticalHelper+<GenerateClassReader>c__AnonStorey0.<>m__0 (System.Runtime.Serialization.XmlReaderDelegator xr, System.Runtime.Serialization.XmlObjectSerializerReadContext ctx, System.Xml.XmlDictionaryString[] memberNames, System.Xml.XmlDictionaryString[] memberNamespaces) [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:15 
  at System.Runtime.Serialization.ClassDataContract.ReadXmlValue (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Runtime.Serialization.XmlObjectSerializerReadContext context) [0x00007] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs:457 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadCollectionItem (System.Runtime.Serialization.CollectionDataContract collectionContract, System.Type itemType, System.String itemName, System.String itemNs) [0x00023] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:570 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadCollection (System.Runtime.Serialization.CollectionDataContract collectionContract) [0x00187] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:435 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadCollectionFromXml (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Runtime.Serialization.XmlObjectSerializerReadContext context, System.Xml.XmlDictionaryString itemName, System.Xml.XmlDictionaryString itemNamespace, System.Runtime.Serialization.CollectionDataContract collectionContract) [0x00025] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:112 
  at System.Runtime.Serialization.XmlFormatReaderGenerator+CriticalHelper+<GenerateCollectionReader>c__AnonStorey1.<>m__0 (System.Runtime.Serialization.XmlReaderDelegator xr, System.Runtime.Serialization.XmlObjectSerializerReadContext ctx, System.Xml.XmlDictionaryString inm, System.Xml.XmlDictionaryString ins, System.Runtime.Serialization.CollectionDataContract cc) [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs:20 
  at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Runtime.Serialization.XmlObjectSerializerReadContext context) [0x0003a] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/CollectionDataContract.cs:1445 
  at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue (System.Runtime.Serialization.DataContract dataContract, System.Runtime.Serialization.XmlReaderDelegator reader) [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs:1082 
  at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize (System.Runtime.Serialization.XmlReaderDelegator reader, System.String name, System.String ns, System.Type declaredType, System.Runtime.Serialization.DataContract& dataContract) [0x00282] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs:233 
  at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Type declaredType, System.Runtime.Serialization.DataContract dataContract, System.String name, System.String ns) [0x0000e] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs:144 
  at System.Runtime.Serialization.DataContractSerializer.InternalReadObject (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Boolean verifyObjectName, System.Runtime.Serialization.DataContractResolver dataContractResolver) [0x0013e] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/DataContractSerializer.cs:486 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions (System.Runtime.Serialization.XmlReaderDelegator reader, System.Boolean verifyObjectName, System.Runtime.Serialization.DataContractResolver dataContractResolver) [0x0007a] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs:313 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions (System.Runtime.Serialization.XmlReaderDelegator reader, System.Boolean verifyObjectName) [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs:294 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObject (System.Xml.XmlDictionaryReader reader) [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs:257 
  at Xamarin.Forms.Platform.Android.Deserializer+<>c.<DeserializePropertiesAsync>b__1_0 () [0x0003b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Deserializer.cs:31 


if I use this

directory = (string[])Application.Current.Properties["PathFileConfig"];

I have an exception 
The given key was not present in the dictionary.
Comment 1 Jimmy [MSFT] 2017-03-23 18:21:51 UTC
Created attachment 20767 [details]
sample project

I was unable to reproduce this issue with the sample project I am attaching. 

Does this only happen on Android? What version of Forms are you using? Can you also attach a project that reproduces the issue so we can continue looking into this? Thanks!
Comment 2 Alessandro 2017-03-23 18:24:24 UTC
Have you tried to save a string[] in the property?
Comment 3 Jimmy [MSFT] 2017-03-23 18:52:31 UTC
Yes, I tried:

> Application.Current.Properties["TestProperty"] = new string[] { "Item1", "Item2"};
Comment 4 Alessandro 2017-03-23 20:54:26 UTC
@Jimmy I have tested your app.
1- Execute it
2- Press Home button (App to background)
3- Press App Icon (now app goes to foreground)
4- exception!

I test on Zebra WT6000 API 22 Android.

Let me know
Comment 5 Rui Marinho 2017-06-20 18:28:55 UTC
Just tried diferent emulators and LG nexus 5 device and can't make it crash.