Код: Выделить всё
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.InvalidCastException: Cannot cast from source type to destination type.
[MonoDroid] at (wrapper castclass) object.__castclass_with_cache (object,intptr,intptr)
[MonoDroid] at Android.Runtime.JavaSet`1.FromJniHandle (intptr,Android.Runtime.JniHandleOwnership)
[MonoDroid] at Android.Content.ISharedPreferencesInvoker.GetStringSet (string,System.Collections.Generic.ICollection`1)
[MonoDroid] at canvastix.MultiSelectListPreference.OnDialogClosed (bool)
[MonoDroid] at Android.Preferences.DialogPreference.n_OnDialogClosed_Z (intptr,intptr,bool)
[MonoDroid] at (wrapper dynamic-method) object.4bc48339-d8f3-443a-a584-0088f55fe375 (intptr,intptr,bool)
[mono]
[mono] Unhandled Exception:
[mono] System.InvalidCastException: Cannot cast from source type to destination type.
[mono] at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
[mono] at Android.Runtime.JavaSet`1[System.String].FromJniHandle (IntPtr handle, JniHandleOwnership transfer) [0x00000] in :0
[mono] at Android.Content.ISharedPreferencesInvoker.GetStringSet (System.String key, ICollection`1 defValues) [0x00000] in :0
[mono] at canvastix.MultiSelectListPreference.OnDialogClosed (Boolean positiveResult) [0x00000] in :0
[mono] at Android.Preferences.DialogPreference.n_OnDialogClosed_Z (IntPtr jnienv, IntPtr native__this, Boolean positiveResult) [0x00000] in :0
[mono] at (wrapper dynamic-method) object:4bc48339-d8f3-443a-a584-0088f55fe375 (intptr,intptr,bool)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type.
[mono-rt] at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
[mono-rt] at Android.Runtime.JavaSet`1[System.String].FromJniHandle (IntPtr handle, JniHandleOwnership transfer) [0x00000] in :0
[mono-rt] at Android.Content.ISharedPreferencesInvoker.GetStringSet (System.String key, ICollection`1 defValues) [0x00000] in :0
[mono-rt] at canvastix.MultiSelectListPreference.OnDialogClosed (Boolean positiveResult) [0x00000] in :0
[mono-rt] at Android.Preferences.DialogPreference.n_OnDialogClosed_Z (IntPtr jnienv, IntPtr native__this, Boolean positiveResult) [0x00000] in :0
[mono-rt] at (wrapper dynamic-method) object:4bc48339-d8f3-443a-a584-0088f55fe375 (intptr,intptr,bool)
Код: Выделить всё
Button button = FindViewById (Resource.Id.button);
button.Click += delegate {
//Read value
ISharedPreferences Prefs = PreferenceManager.GetDefaultSharedPreferences (this);
ICollection list = Prefs.GetStringSet("list", new List());
Toast.MakeText(this, "Total items: " + list.Count, ToastLength.Short).Show();
};
Код: Выделить всё
Код: Выделить всё
Код: Выделить всё
1
2
Item 1
Item 2
Через неделю я понял, что это, должно быть, ошибка в Xamarin. Так что, если вы найдете обходной путь, это тоже будет здорово.
Подробнее здесь: https://stackoverflow.com/questions/269 ... texception
Мобильная версия