Android에서 Xamarin Forms의 Application.Current.Properties가 저장되지 않음

5331 단어 XamarinXamarin.Forms

문제



Android에서 Application.Current.Properties에 저장된 값이 앱을 다시 시작하면 복원되지 않습니다.
디버그 빌드에서는 정상적으로 복원되지만, 릴리스 빌드일 때만 안 된다.
iOS에서는 정상적으로 복원된다.

런타임 로그에 다음과 같이 표시됩니다.
Xamarin.Forms PropertyStore: Exception while reading Application properties: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00011] in <8b2a39fe03af4d18bd69fa49d25dc113>:0 
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <8b2a39fe03af4d18bd69fa49d25dc113>:0 
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x0000c] in <8b2a39fe03af4d18bd69fa49d25dc113>:0 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.StoreCollectionValue (System.Object collection, System.Type valueType, System.Object value, System.Runtime.Serialization.CollectionDataContract collectionContract) [0x00032] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  at System.Runtime.Serialization.XmlFormatReaderInterpreter.ReadCollection (System.Runtime.Serialization.CollectionDataContract collectionContract) [0x001e4] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  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 <60b7cf293a0e42789c2b4630bbb58b98>:0 
  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) [0x0000c] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Runtime.Serialization.XmlObjectSerializerReadContext context) [0x0004e] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue (System.Runtime.Serialization.DataContract dataContract, System.Runtime.Serialization.XmlReaderDelegator reader) [0x00000] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  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 <60b7cf293a0e42789c2b4630bbb58b98>:0 
  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 <60b7cf293a0e42789c2b4630bbb58b98>:0 
  at System.Runtime.Serialization.DataContractSerializer.InternalReadObject (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Boolean verifyObjectName, System.Runtime.Serialization.DataContractResolver dataContractResolver) [0x0013e] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions (System.Runtime.Serialization.XmlReaderDelegator reader, System.Boolean verifyObjectName, System.Runtime.Serialization.DataContractResolver dataContractResolver) [0x0007a] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions (System.Runtime.Serialization.XmlReaderDelegator reader, System.Boolean verifyObjectName) [0x00000] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObject (System.Xml.XmlDictionaryReader reader) [0x00007] in <60b7cf293a0e42789c2b4630bbb58b98>:0 
  at Xamarin.Forms.Platform.Android.Deserializer+<>c.<DeserializePropertiesAsync>b__1_0 () [0x0003b] in <95895bcb439e42ebb8e7134a545f1acc>:0 

해결책



htps : // ふふる ms. 마린. 코 m / ぢ s 쿠시 온 / 64410 / 닌 - 안 d 로이 d ぃ ん 케 r 오 p 치 온 s는 온 - r-p-p 로페 rtys와 re-r t-rk
에 써 있지만, 요점은 Xamarin Forms의 버그라고 하는 것보다 링커의 문제로, 워크 어라운드는 2개 있다.
  • 안드로이드 프로젝트 옵션에서 "링크하지 않음"을 선택하십시오
  • 마찬가지로 옵션으로 '무시할 어셈블리'에 System.Runtime.Serialization 추가

  • 1 또는 2 중 하나를 수행하면 된다.
    우리 쪽에서는 2만 실시해 잘 되는 것을 확인했다.

    좋은 웹페이지 즐겨찾기