Closed dsancho closed 8 years ago
What kind of data are you trying to save? It only supports specific data: https://github.com/jamesmontemagno/Mvx.Plugins.Settings/blob/master/Refractored.MvxPlugins.Settings.Touch/MvxTouchSettings.cs
Simple strings. If I comment the line where the ServiceClient is created then it works ok
hi @jamesmontemagno I am facing the same problem right now. Did you find a solution for this @dsancho ?
@GKersten are you just using the azure mobile service from NuGet? Do you have a small repo I can test?
Are you trying to save your key or something in the settings?
Hi James I have the same problem. To reproduce the issue only you need to add this line to your App.cs in your Core.dll
// This MobileServiceClient has been configured to communicate with your Mobile Service's url
// and application key. You're all set to start working with your Mobile Service!
public static MobileServiceClient MobileService = new MobileServiceClient(
"https://somedomain.azure-mobile.net/",
"somekey"
);
is the "somekey" coming from the Settings library?
What build issue are you getting?
"somekey" is a random string, I got it from the Azure site. I'm using the last version from Nuget of your plugin and of the Azure Mobile Service SDK
As a simple workaround, I edited the method "GetValueOrDefault" like this:
public T GetValueOrDefault
object value = null;
var typeCode = Type.GetTypeCode(typeOf);
switch (typeCode)
{
case TypeCode.Decimal:
value = (decimal)temporalPref.GetLong(key, (long)Convert.ToDecimal(defaultValue, System.Globalization.CultureInfo.InvariantCulture));
break;
case TypeCode.Boolean:
value = temporalPref.GetBoolean(key, Convert.ToBoolean(defaultValue));
break;
case TypeCode.Int64:
value = (Int64)temporalPref.GetLong(key, (long)Convert.ToInt64(defaultValue, System.Globalization.CultureInfo.InvariantCulture));
break;
case TypeCode.String:
value = temporalPref.GetString(key, Convert.ToString(defaultValue));
break;
case TypeCode.Double:
value = (double)temporalPref.GetLong(key, (long)Convert.ToDouble(defaultValue, System.Globalization.CultureInfo.InvariantCulture));
break;
case TypeCode.Int32:
value = temporalPref.GetInt(key, Convert.ToInt32(defaultValue, System.Globalization.CultureInfo.InvariantCulture));
break;
case TypeCode.Single:
value = temporalPref.GetFloat(key, Convert.ToSingle(defaultValue, System.Globalization.CultureInfo.InvariantCulture));
break;
case TypeCode.DateTime:
var ticks = temporalPref.GetLong(key, -1);
if (ticks == -1)
value = defaultValue;
else
value = new DateTime(ticks);
break;
default:
if (defaultValue is Guid)
{
var outGuid = Guid.Empty;
Guid.TryParse(temporalPref.GetString(key, Guid.Empty.ToString()), out outGuid);
value = outGuid;
}
else
{
throw new ArgumentException(string.Format("Value of type {0} is not supported.", value.GetType().Name));
}
break;
}
return null != value ? (T)value : defaultValue;
}
}
I will take a look at it this week and see what the real root cause is.
Thanks for the code sample. It has been hard to look into as there are not many reports and no one gave me a good repo at all or details.
This package is obsolete, please use: https://www.nuget.org/packages/Xam.Plugins.Settings
After creating the MobileServiceClient in Android then the settings stop working when reading values.
The exception throwed is 'System.ArgumentException: 'jobject' must not be IntPtr.Zero.'
I have done several tests and always is the same, just create the MobileServiceClient and Settings stop working.