jamesmontemagno / SettingsPlugin

Read and Write Settings Plugin for Xamarin and Windows
MIT License
324 stars 80 forks source link

Cannot store/retrieve strings since release 3.1.1 #138

Closed xperseguers closed 6 years ago

xperseguers commented 6 years ago

Version 3.1.1 is the last version I could successfully store/retrieve string-based settings. It crashes since I updated to 4.0.0.7 on iOS. Since then I had to downgrade to 3.1.1 when compiling for Android.

Bug Information

Version Number of Plugin: 4.0.0.10-beta Device Tested On: Samsung S7 Edge Simulator Tested On: Version of VS: 7.6.6 Version of Xamarin: Xamarin.Forms 3.2.83. Versions of other things you are using:

Steps to reproduce the Behavior

AppSettings.AddOrUpdateValue ("somekey", "some value");

Expected Behavior

var foo = AppSettings.GetValueOrDefault("somekey");
// This should contain "some value" but instead throws an exception

Actual Behavior

Throws exception System.TypeLoadException (Failure has occured while loading a type.)

jamesmontemagno commented 6 years ago

did you already use this key and save it as something else?

jamesmontemagno commented 6 years ago

i am confused where you issue is... on ios or on android? on which version of the nuget?

xperseguers commented 6 years ago

No, this key was not yet used. In fact, I really tested (again) with string "somekey" as in my example before opening the ticket.

This is on Android, not iOS, as written, the device where it fails is a Samsung S7 Edge. I tested on another device a Huawai "something" and the app is crashing as well. I wrote about iOS in the beginning because the app is using Xamarin.Forms and deployed to both iOS and Android devices but the problem really only appeared on Android and the last known working version there is v3.1.1.

xperseguers commented 6 years ago

I thought that it could possibly be related to using newline characters in the value so I tried to change to underscore _, not better and finally really tested with somekey and some value (exactly those strings).

xperseguers commented 6 years ago

Don't know if something's related but I cannot compile in release mode since when I try I get this:

The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'Plugin.Settings.Abstractions.ISettings
<CustomClass>::get_AppSettings()' ---> Mono.Cecil.ResolutionException
Failed to resolve Plugin.Settings.Abstractions.ISettings
  at Mono.Linker.Steps.MarkStep.HandleUnresolvedType (Mono.Cecil.TypeReference reference)
...
jamesmontemagno commented 6 years ago

Maybe turn off linking for the assemblies... not sure what your link settings are set to. I need a sample reproduction please.

xperseguers commented 6 years ago

Looks like somehow I had a version mixup for the plugin between the various parts of the application. Really don't know how this could happen but everything works fine now and the incompatibilities I faced since version 3.1.1 might as well have been related to some compatibility packages for Android which were not up-to-date (it's always a bit tricky since Xamarin.Forms does not systematically support the very latest available version of some compatibility library on Android and I ended up having quite some libraries which were announced as having a new version available but for which I did not try to upgrade anymore since I got used to trying to update for nuts and having to revert afterwards).

Sorry for disturbing and thanks for this very useful package.