Not able to replace entire observable collection. As it throws exception.
How do I replace entire observable collection item? The suggested answers from other threads didn't work. Tried the following. Any suggestion would help on this.
Xaml
<Picker
x:Name=“Picker1”
Style="{StaticResource PickerStyle}"
ItemsSource="{Binding CodeNumberList}"
SelectedItem="{Binding CodeNumberText}”>
<Picker.Behaviors>
<xct:EventToCommandBehavior
EventName="SelectedIndexChanged"
Command="{Binding ItemChangedCommand}"
CommandParameter="{Binding Source={x:Reference Picker1},
Path=SelectedItem}"/>
</Picker.Behaviors>
</Picker>
<Picker
x:Name=“Picker2”
Style="{StaticResource PickerStyle}"
ItemsSource="{Binding PhoneNumberList}"
SelectedItem="{Binding PhoneNumberText}”>
</Picker>
ViewModel
private ObservableCollection<string> _phumberList;
public ObservableCollection<string> PhNumberList
{
get
{
return _phumberList;
}
set
{
_phumberList = value;
RaisePropertyChanged(nameof(this.PhNumberList));
}
}
private void ItemChangedCommandHandler(string obj)
{
PopulatePhoneList();
}
private void PopulatePhoneList()
{
// tried clearing PhNumberList.Clear() and then added items, that didn't work too
//Invalid cast exception thrown in below line
PhNumberList = new ObservableCollection<string>();
foreach (var item in CurrentUser?.InformationDetailItems)
{
PhNumberList.Add (item.PhoneNumber);
}
}
public On NavigatedTo(){
// populate default pickerList
PopulatePhoneList();
}
Exception :
//Invalid cast exception thrown in below line
PhNumberList = new ObservableCollection();
Stack Trace
at (wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
at Prism.Commands.DelegateCommand`1[T].CanExecute (System.Object parameter) [0x00000] in d:\a\1\s\Source\Prism\Commands\DelegateCommand{T}.cs:113
at Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.CanExecute (System.Object parameter) [0x00000] in d:\a\1\s\Source\Prism\Commands\DelegateCommandBase.cs:67
at Xamarin.CommunityToolkit.Behaviors.EventToCommandBehavior.OnTriggerHandled (System.Object sender, System.Object eventArgs) [0x00039] in <823f4019dc404dea9e9331c7114e4863>:0
at Xamarin.Forms.Picker.OnSelectedIndexChanged (System.Object bindable, System.Object oldValue, System.Object newValue) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:283
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:512
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0004d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:374
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:349
at Xamarin.Forms.Picker.set_SelectedIndex (System.Int32 value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:114
at Xamarin.Forms.Picker.OnItemsCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00007] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:205
at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionReset () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:362
at System.Collections.ObjectModel.ObservableCollection`1[T].ClearItems () [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:166
at System.Collections.ObjectModel.Collection`1[T].Clear () [0x00014] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:81
at Xamarin.Forms.Internals.LockableObservableListWrapper.InternalClear () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\LockableObservableListWrapper.cs:71
at Xamarin.Forms.Picker.ResetItems () [0x00009] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:273
at Xamarin.Forms.Picker.OnItemsSourceChanged (System.Collections.IList oldValue, System.Collections.IList newValue) [0x0004c] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:231
at Xamarin.Forms.Picker.OnItemsSourceChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:213
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:512
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160
at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56
at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:762
at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:773
at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:666
at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Prism.Mvvm.BindableBase.OnPropertyChanged (System.ComponentModel.PropertyChangedEventArgs args) [0x00000] in d:\a\1\s\Source\Prism\Mvvm\BindableBase.cs:99
at Prism.Mvvm.BindableBase.OnPropertyChanged (System.String propertyName) [0x00000] in d:\a\1\s\Source\Prism\Mvvm\BindableBase.cs:90
at Prism.Mvvm.BindableBase.RaisePropertyChanged (System.String propertyName) [0x00000] in d:\a\1\s\Source\Prism\Mvvm\BindableBase.cs:76
-->at ProjectMobile.ViewModels.DarFormPageViewModel.set_EquipmentNumberList (System.Collections.ObjectModel.ObservableCollection`1[T] value) [0x00008] in /Users/vpo1/Project-Mobile/MobileApp/ProjectMobile.ViewModels/PhFormPageViewModel:104 <--
at ProjectMobile.ViewModels.DarFormPageViewModel.PopulateEquipmentList (System.Boolean IsFromNavigatedTo) [0x00013] in /Users/vpo1/Project-Mobile/MobileApp/ProjectMobile.ViewModels/PhFormPageViewModel:940
at ProjectMobile.ViewModels.DarFormPageViewModel.DeliveryItemChangedCommandHandler (System.String obj) [0x00008] in /Users/vpo1/Project-Mobile/MobileApp/ProjectMobile.ViewModels/PhFormPageViewModel:61
at Prism.Commands.DelegateCommand`1[T].Execute (T parameter) [0x00000] in d:\a\1\s\Source\Prism\Commands\DelegateCommand{T}.cs:82
at Prism.Commands.DelegateCommand`1[T].Execute (System.Object parameter) [0x00000] in d:\a\1\s\Source\Prism\Commands\DelegateCommand{T}.cs:103
at Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.Execute (System.Object parameter) [0x00000] in d:\a\1\s\Source\Prism\Commands\DelegateCommandBase.cs:62
at Xamarin.CommunityToolkit.Behaviors.EventToCommandBehavior.OnTriggerHandled (System.Object sender, System.Object eventArgs) [0x00042] in <823f4019dc404dea9e9331c7114e4863>:0
at Xamarin.Forms.Picker.OnSelectedIndexChanged (System.Object bindable, System.Object oldValue, System.Object newValue) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:283
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:512
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0004d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:374
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:349
at Xamarin.Forms.Picker.set_SelectedIndex (System.Int32 value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:114
at Xamarin.Forms.Picker.UpdateSelectedIndex (System.Object selectedItem) [0x00008] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:296
at Xamarin.Forms.Picker.OnSelectedItemChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00006] in D:\a\1\s\Xamarin.Forms.Core\Picker.cs:289
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:512
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160
at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56
at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:762
at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:773
at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:666
at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Prism.Mvvm.BindableBase.OnPropertyChanged (System.ComponentModel.PropertyChangedEventArgs args) [0x00000] in d:\a\1\s\Source\Prism\Mvvm\BindableBase.cs:99
at Prism.Mvvm.BindableBase.OnPropertyChanged (System.String propertyName) [0x00000] in d:\a\1\s\Source\Prism\Mvvm\BindableBase.cs:90
at Prism.Mvvm.BindableBase.RaisePropertyChanged (System.String propertyName) [0x00000] in d:\a\1\s\Source\Prism\Mvvm\BindableBase.cs:76
at ProjectMobile.ViewModels.DarFormPageViewModel.set_BolNumberText (System.String value) [0x00008] in /Users/vpo1/Project-Mobile/MobileApp/ProjectMobile.ViewModels/PhFormPageViewModel:118
at ProjectMobile.ViewModels.DarFormPageViewModel.OnNavigatedTo (Prism.Navigation.INavigationParameters parameters) [0x00170] in /Users/vpo1/Project-Mobile/MobileApp/ProjectMobile.ViewModels/PhFormPageViewModel:863
Removing this part of the code should resolve the problem:
<xct:EventToCommandBehavior
EventName="SelectedIndexChanged"
Command="{Binding ItemChangedCommand}"
CommandParameter="{Binding Source={x:Reference Picker1},
Path=SelectedItem}"/>
This can be done in many other ways, like using the CodeNumberText property to handle it. As it is likely a bug in that open source component you can submit the bug to their GitHub or fix it yourself.
Related
When trying to use Xamarin FFImageLoading plugin on iOs I get this exception:
System.Exception: Please call CachedImageRenderer.Init method in a platform specific project to use FFImageLoading!
at FFImageLoading.Forms.CachedImage.OnSourcePropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00007] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:133
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a\1\s\Xam
arin.Forms.Core\BindableObject.cs:417
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:573
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99
at FFImageLoading.Forms.CachedImage.set_Source (Xamarin.Forms.ImageSource value) [0x00000] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:173
at Demo.MainViewModel..ctor () [0x0001f] in <4cd5393447f94973bb9eef7c0de8880d>:0
at FullCameraApp.CameraPage.getLayoutImage (System.Int32 index) [0x00001] in <4cd5393447f94973bb9eef7c0de8880d>:0
at FullCameraApp.CameraPage..ctor (ScoreScan.webServices.WebServices webServices, System.Collections.Generic.List`1[T] imageBytesList) [0x0060b] in <4cd5393447f94973bb9eef7c0de8880d>:0
at ScoreScan.App..ctor () [0x0
0025] in <4cd5393447f94973bb9eef7c0de8880d>:0
at ScoreScan.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x0000d] in <4cd5393447f94973bb9eef7c0de8880d>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at ScoreScan.iOS.Application.Main (System.String[] args) [0x00001] in <4cd5393447f94973bb9eef7c0de8880d>:0
2018-10-08 19:47:10.229 ScoreScan.iOS[324:13181] Unhandled managed exception:
Please call CachedImageRenderer.Init method in a platform specific project to use FFImageLoading! (System.Exception)
at FFImageLoading.Forms.CachedImage.OnSourcePropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00007] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:133
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a
\1\s\Xamarin.Forms.Core\BindableObject.cs:417
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:573
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99
at FFImageLoading.Forms.CachedImage.set_Source (Xamarin.Forms.ImageSource value) [0x00000] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:173
at Demo.MainViewModel..ctor () [0x0001f] in <4cd5393447f94973bb9eef7c0de8880d>:0
at FullCameraApp.CameraPage.getLayoutImage (System.Int32 index) [0x00001] in <4cd5393447f94973bb9eef7c0de8880d>:0
at FullCameraApp.CameraPage..ctor (ScoreScan.webServices.WebServices webServices, System.Collections.Generic.List`1[T] imageBytesList) [0x0060b] in <4cd5393447f94973bb9eef7c0de8880d>:0
at ScoreScan.App..ctor
ktrace:
How Can I solve this exception?
Call CachedImageRenderer.Init after global::Xamarin.Forms.Forms.Init(); in FinishedLaunching method present in AppDelegate.cs file of iOS project.
It clearly mention that you need to call Init method inside this. The details will be given in the github repository of FFImageLoading plugin
It is mentioned in the following link
I update my Unity from 5.2 to 5.6, this is success. But after update, i can't open file script. This is Error
The file '/Users/vietbac/Desktop/New Unity Project 1/Assets/NewBehaviourScript.cs' could not be opened. Error while loading style :Default
System.IO.IOException: Error while loading style :Default --->
System.TypeInitializationException: An exception was thrown by the
type initializer for System.Drawing.KnownColors --->
System.TypeInitializationException: An exception was thrown by the
type initializer for System.Drawing.GDIPlus --->
System.DllNotFoundException:
/Applications/Unity/MonoDevelop.app/Contents/MacOS/../Frameworks/Mono.framework/Versions/2.10.12/lib/libgdiplus.dylib
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup
(ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in :0
--- End of inner exception stack trace --- at System.Drawing.KnownColors..cctor () [0x00000] in :0
--- End of inner exception stack trace --- at System.Drawing.ColorConverter.StaticConvertFromString
(ITypeDescriptorContext context, System.String s,
System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Drawing.ColorConverter.ConvertFrom
(ITypeDescriptorContext context, System.Globalization.CultureInfo
culture, System.Object value) [0x00000] in :0 at
System.ComponentModel.TypeConverter.ConvertFrom (System.Object o)
[0x00000] in :0 at
System.ComponentModel.TypeConverter.ConvertFromString (System.String
text) [0x00000] in :0 at
System.Drawing.ColorTranslator.FromHtml (System.String htmlColor)
[0x00000] in :0 at
Mono.TextEditor.Highlighting.ColorScheme.GetColorFromString
(System.String colorString) [0x001c0] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs:578
at Mono.TextEditor.Highlighting.ColorScheme.SetChunkStyle
(System.String name, System.String weight, System.String foreColor,
System.String backColor) [0x00038] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs:514
at Mono.TextEditor.Highlighting.ColorScheme.ReadStyleTree
(System.Xml.XmlReader reader, Mono.TextEditor.Highlighting.ColorScheme
result, System.String curName, System.String curWeight, System.String
curColor, System.String curBgColor) [0x000b8] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs:599
at
Mono.TextEditor.Highlighting.ColorScheme+c__AnonStorey32.<>m__43
() [0x000e0] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs:625
at
Mono.TextEditor.Highlighting.XmlReadHelper+c__AnonStorey19.<>m__D
(Mono.TextEditor.Highlighting.ReadCallbackData data) [0x00000] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/XmlReadHelper.cs:55
at Mono.TextEditor.Highlighting.XmlReadHelper.ReadList
(System.Xml.XmlReader reader, ICollection1 endNodes,
Mono.TextEditor.Highlighting.ReaderCallbackWithData callback)
[0x0008b] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/XmlReadHelper.cs:91
at Mono.TextEditor.Highlighting.XmlReadHelper.ReadList
(System.Xml.XmlReader reader, ICollection1 endNodes,
Mono.TextEditor.Highlighting.ReaderCallback callback) [0x0000d] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/XmlReadHelper.cs:54
at Mono.TextEditor.Highlighting.XmlReadHelper.ReadList
(System.Xml.XmlReader reader, System.String endNode,
Mono.TextEditor.Highlighting.ReaderCallback callback) [0x00000] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/XmlReadHelper.cs:50
at Mono.TextEditor.Highlighting.ColorScheme.LoadFrom
(System.Xml.XmlReader reader) [0x00018] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs:615
at Mono.TextEditor.Highlighting.SyntaxModeService.LoadStyle
(System.String name) [0x0003c] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs:111
--- End of inner exception stack trace --- at Mono.TextEditor.Highlighting.SyntaxModeService.LoadStyle
(System.String name) [0x00053] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs:113
at Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle
(System.String name) [0x0002c] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs:83
at Mono.TextEditor.TextEditorOptions.GetColorStyle () [0x00000] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorOptions.cs:492
at MonoDevelop.SourceEditor.StyledSourceEditorOptions.GetColorStyle ()
[0x00000] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs:192
at Mono.TextEditor.TextArea.OptionsChanged (System.Object sender,
System.EventArgs args) [0x00038] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs:685
at Mono.TextEditor.TextArea.set_Options (ITextEditorOptions value)
[0x00066] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs:157
at Mono.TextEditor.TextEditor.set_Options (ITextEditorOptions value)
[0x00000] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextEditor.cs:414
at MonoDevelop.SourceEditor.ExtensibleTextEditor..ctor
(MonoDevelop.SourceEditor.SourceEditorView view) [0x00028] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs:75
at MonoDevelop.SourceEditor.SourceEditorWidget..ctor
(MonoDevelop.SourceEditor.SourceEditorView view) [0x00077] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs:284
at MonoDevelop.SourceEditor.SourceEditorView..ctor () [0x000ca] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs:189
at MonoDevelop.SourceEditor.SourceEditorDisplayBinding.CreateContent
(FilePath fileName, System.String mimeType,
MonoDevelop.Projects.Project ownerProject) [0x00000] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorDisplayBinding.cs:94
at MonoDevelop.Ide.Gui.LoadFileWrapper.Invoke (System.String fileName)
[0x00033] in
/home/builduser/buildslave/monodevelop/build/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs:1182
i was trying to implement the ValueConverter for MVVMCross, but aparently it is not working as i would expect. So at the moment i just got another Property which does the conversion (MvxColor to TextColor) for me and bind it to my Layout.
But ofc i would rather use the value converters, so maybe you have an idea what iam doing wrong:
The binding error iam currently getting:
06-09 16:29:29.820 I/MvxBind (16312): 61,64 Problem seen during binding execution for binding TextColor for Changed - problem InvalidCastException: Specified cast is not valid.
06-09 16:29:29.820 I/MvxBind (16312): at MvvmCross.Plugins.Color.Droid.BindingTargets.MvxTextViewTextColorBinding.SetValueImpl (System.Object target, System.Object value) [0x0000a] in <filename unknown>:0
06-09 16:29:29.820 I/MvxBind (16312): at MvvmCross.Binding.Bindings.Target.MvxConvertingTargetBinding.SetValue (System.Object value) [0x00088] in <filename unknown>:0
06-09 16:29:29.820 I/MvxBind (16312): at MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (System.Object value) [0x00024] in <filename unknown>:0
MvxBind:Error: 61,64 Problem seen during binding execution for binding TextColor for Changed - problem InvalidCastException: Specified cast is not valid.
06-09 16:29:29.820 I/mono-stdout(16312): MvxBind:Error: 61,64 Problem seen during binding execution for binding TextColor for Changed - problem InvalidCastException: Specified cast is not valid.
06-09 16:29:29.820 I/mono-stdout(16312): at MvvmCross.Plugins.Color.Droid.BindingTargets.MvxTextViewTextColorBinding.SetValueImpl (System.Object target, System.Object value) [0x0000a] in <filename unknown>:0
at MvvmCross.Plugins.Color.Droid.BindingTargets.MvxTextViewTextColorBinding.SetValueImpl (System.Object target, System.Object value) [0x0000a] in <filename unknown>:0
at MvvmCross.Binding.Bindings.Target.MvxConvertingTargetBinding.SetValue (System.Object value) [0x00088] in <filename unknown>:0
06-09 16:29:29.830 I/mono-stdout(16312): at MvvmCross.Binding.Bindings.Target.MvxConvertingTargetBinding.SetValue (System.Object value) [0x00088] in <filename unknown>:0
at MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (System.Object value) [0x00024] in <filename unknown>:0
06-09 16:29:29.830 I/mono-stdout(16312): at MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (System.Object value) [0x00024] in <filename unknown>:0
[0:] MvxBind:Error: 61,64 Problem seen during binding execution for binding TextColor for Changed - problem InvalidCastException: Specified cast is not valid.
at MvvmCross.Plugins.Color.Droid.BindingTargets.MvxTextViewTextColorBinding.SetValueImpl (System.Object target, System.Object value) [0x0000a] in <filename unknown>:0
at MvvmCross.Binding.Bindings.Target.MvxConvertingTargetBinding.SetValue (System.Object value) [0x00088] in <filename unknown>:0
at MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (System.Object value) [0x00024] in <filename unknown>:0
My Layout-Snippet:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:inputType="numberDecimal|numberSigned"
android:textColor="#color/schaefflerlightgreen"
local:MvxBind="TextColor Changed,Converter=MvxBoolToColorValueConverter" />
The two converter classes i tried out:
public class MvxBoolToMvxColorValueConverter: MvxColorValueConverter<bool>
{
protected override MvxColor Convert(bool value, object parameter, CultureInfo culture)
{
if (value)
{
// FF0000
return new MvxColor(255, 0, 0);
}
//227D41
return new MvxColor(34, 125, 65);
}
}
public class MvxBoolToColorValueConverter : MvxValueConverter<bool, Color>
{
protected override Color Convert(bool value, Type targetType, object parameter, CultureInfo culture)
{
if (value)
{
// FF0000
return new Color(255, 0, 0);
}
//227D41
return new Color(34, 125, 65);
}
}
The thing is the binding is generally working with a MvxColor-Property, just the conversion seems to be an issue. So probably i just missed something.
So thanks for your help.
Edith: And the property...
public bool Changed { get { return m_sValue != m_sSyncValue; } }
Strip off the Mvx-prefix and the ValueConverter-suffix from the converter name in your binding:
Change
local:MvxBind="TextColor Changed,Converter=MvxBoolToColorValueConverter" />
to
local:MvxBind="TextColor Changed,Converter=BoolToColor" />
This behaviour is described in the documentation for ValueConverters:
This sweep locates all instanciable classes which implement IMvxValueConverter
within your assemblies creates an instance of each one registers the
instance with the name stripped of any Mvx prefix and any
ValueConverter or Converter postfix. So, for example, the following
class names will all be registered with the same ValueConverter name
of "Foo":
Foo, FooValueConverter, FooConverter, MvxFooValueConverter,
MvxFooConverter
I'm trying to add Realm to my app (Xamarin Android). Starting with emulator first (Xaamrin android player - Nexus 5 with Android Lollipop).
Github Issue here
My code:
protected override async void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MyActivitylayout);
....
try
{
var path = AndroidIoHelper.CreateFileInAppFolder(AndroidIoHelper.GetAppDataFolder(), "tlm_db", "realm");
var realm = Realm.GetInstance(path);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
.......
}
Exception I'm getting:
Realms.RealmFileAccessErrorException: Operation not permitted at
Realms.NativeCommon.ExceptionThrower (IntPtr exceptionCode, IntPtr
utf8String, IntPtr stringLen) [0x0003b] in :0 at
(wrapper native-to-managed) Realms.NativeCommon:ExceptionThrower
(intptr,intptr,intptr) at (wrapper managed-to-native)
Realms.NativeSharedRealm:open
(Realms.SchemaHandle,string,intptr,intptr,intptr,byte[],ulong) 05-15
12:57:18.384 I/mono-stdout( 5250):
Realms.RealmFileAccessErrorException: Operation not permitted 05-15
12:57:18.384 I/mono-stdout( 5250): at
Realms.NativeCommon.ExceptionThrower (IntPtr exceptionCode, IntPtr
utf8String, IntPtr stringLen) [0x0003b] in :0 05-15
12:57:18.384 I/mono-stdout( 5250): at (wrapper native-to-managed)
Realms.NativeCommon:ExceptionThrower (intptr,intptr,intptr) 05-15
12:57:18.385 I/mono-stdout( 5250): at (wrapper managed-to-native)
Realms.NativeSharedRealm:open
(Realms.SchemaHandle,string,intptr,intptr,intptr,byte[],ulong) 05-15
12:57:18.385 I/mono-stdout( 5250): at Realms.Realm.GetInstance
(Realms.RealmConfiguration config) [0x0010c] in :0
05-15 12:57:18.385 I/mono-stdout( 5250): at Realms.Realm.GetInstance
(System.String databasePath) [0x00019] in :0 05-15
12:57:18.385 I/mono-stdout( 5250): at
MyApp.Activities.SplashScreenActivity+d__4.MoveNext ()
[0x00116] in
C:\Users***\Source\Repos\AppName\MyApp\Activities\SplashScreenActivity.cs:66
at Realms.Realm.GetInstance (Realms.RealmConfiguration config)
[0x0010c] in :0 at Realms.Realm.GetInstance
(System.String databasePath) [0x00019] in :0 at
MyApp.Activities.SplashScreenActivity+d__4.MoveNext ()
[0x00116] in
C:\Users***\Source\Repos\AppName\MyApp\Activities\SplashScreenActivity.cs:66
If I don't specify path I'm getting (var realm = Realm.GetInstance();):
System.ArgumentNullException: Value cannot be null. Parameter name:
type at System.Activator.CreateInstance (System.Type type, Boolean
nonPublic) [0x00006] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/activator.cs:205
05-15 13:05:05.257 I/mono-stdout( 5474): System.ArgumentNullException:
Value cannot be null. 05-15 13:05:05.257 I/mono-stdout( 5474):
Parameter name: type 05-15 13:05:05.257 I/mono-stdout( 5474): at
System.Activator.CreateInstance (System.Type type, Boolean nonPublic)
[0x00006] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/activator.cs:205
05-15 13:05:05.257 I/mono-stdout( 5474): at
System.Activator.CreateInstance (System.Type type) [0x00000] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/activator.cs:147
at System.Activator.CreateInstance (System.Type type) [0x00000] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/activator.cs:147
at Realms.Realm.CreateRealmObjectMetadata (System.Type
realmObjectType) [0x0001e] in :0 at
System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement]
(IEnumerable1 source, System.Func2 keySelector, System.Func2
elementSelector, IEqualityComparer1 comparer) [0x0004d] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:855
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement]
(IEnumerable1 source, System.Func2 keySelector, System.Func2
elementSelector) [0x00000] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:847
at Realms.Realm..ctor (Realms.SharedRealmHandle sharedRealmHandle,
Realms.RealmConfiguration config) [0x00037] in <filename unknown>:0
at Realms .Realm.GetInstance (Realms.RealmConfiguration config)
[0x00171] in <filename unknown>:0 at
MyApp.Activities.SplashScreenActivity+<OnCreate>d__4.MoveNext ()
[0x00116] in
C:\Users\***\Source\Repos\AppName\MyApp\Activities\SplashScreenActivity.cs:66
05-15 13:05:05.257 I/mono-stdout( 5474): at
Realms.Realm.CreateRealmObjectMetadata (System.Type realmObjectType)
[0x0001e] in <filename unknown>:0 05-15 13:05:05.257 I/mono-stdout(
5474): at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement]
(IEnumerable1 source, System.Func2 keySelector, System.Func2
elementSelector, IEqualityComparer1 comparer) [0x0004d] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:855
05-15 13:05:05.257 I/mono-stdout( 5474): at
System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement]
(IEnumerable1 source, System.Func2 keySelector, System.Func2
elementSelector) [0x00000] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:847
05-15 13:05:05.257 I/mono-stdout( 5474): at Realms.Realm..ctor
(Realms.SharedRealmHandle sharedRealmHandle, Realms.RealmConfiguration
config) [0x00037] in :0 05-15 13:05:05.257
I/mono-stdout( 5474): at Realms.Realm.GetInstance
(Realms.RealmConfiguration config) [0x00171] in :0
05-15 13:05:05.257 I/mono-stdout( 5474): at
MyApp.Activities.SplashScreenActivity+d__4.MoveNext ()
[0x00116] in
C:\Users***\Source\Repos\AppName\MyApp\Activities\SplashScreenActivity.cs:66
The app has Write external storage permission.
Realm and Fody nuget packages installed properly, Fody weavers are present as expected..
It also crashes with same exception using HTC One X with Android 4.2
The above attempt had other issues. There is a real bug currently in Realm with storage on external storage - see the issue https://github.com/realm/realm-dotnet/issues/554 which is proving awkward to debug.
I have a storyboard. Because I load a view in code (depending on conditions) I haven't used the segue anymore. Now I want to load another view but I'm getting the following error:
System.Reflection.TargetInvocationException was thrown
Exception has been thrown by the target of an invocation.
ListButton.TouchUpInside += (object sender, EventArgs e) => {
MyListController myListController = this.Storyboard.InstantiateViewController ("MyListController") as MyListController;
myListController.EdgesForExtendedLayout = UIRectEdge.None;
if (myListController != null) {
this.NavigationController.PushViewController (myListController, true);
}
};
When the button (ListButton) is pressed the view should be loaded onto the navigation stack. The error occurs with InstantiateViewController.
How can I solve that?
Edit:
I went into MyListController and if I comment the following out the view gets loaded:
public MyListController (IntPtr handle) : base (handle)
{
TableView.RegisterClassForCellReuse (typeof(UITableViewCell), listCellId);
TableView.Source = new MyListDataSource (this);
MyList = new List<string> ();
}
Log:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.Exception: Object
reference not set to an instance of an object at
TestApp.MyListController.ViewDidLoad () [0x0004c] in
/Users/xxx/Projects/TestApp/TestApp/TestApp/MyListController.cs:78
at at (wrapper managed-to-native)
MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper
(intptr,intptr) at
MonoTouch.UIKit.UITableViewController.get_TableView () [0x00000] in
:0 at TestApp.MyListController..ctor (IntPtr
handle) [0x00009] in
/Users/xxx/Projects/TestApp/TestApp/TestApp/MyListController.cs:17
at at (wrapper managed-to-native)
System.Reflection.MonoCMethod:InternalInvoke
(System.Reflection.MonoCMethod,object,object[],System.Exception&) at
System.Reflection.MonoCMethod.InternalInvoke (System.Object obj,
System.Object[] parameters) [0x00002] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:537
--- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj,
System.Object[] parameters) [0x00016] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:543
at System.Reflection.MonoCMethod.DoInvoke (System.Object obj,
BindingFlags invokeAttr, System.Reflection.Binder binder,
System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00095] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:528
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:556
at System.Reflection.ConstructorInfo.Invoke (System.Object[]
parameters) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject[NSObject] (IntPtr
ptr, System.Type type, MissingCtorResolution missingCtorResolution)
[0x00000] in :0 at
MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr
klass, MissingCtorResolution missingCtorResolution) [0x00000] in
:0 at MonoTouch.ObjCRuntime.Runtime.GetNSObject
(IntPtr ptr, MissingCtorResolution missingCtorResolution) [0x00000] in
:0 at MonoTouch.ObjCRuntime.Runtime.GetNSObject
(IntPtr ptr) [0x00000] in :0 at
MonoTouch.UIKit.UIStoryboard.InstantiateViewController (System.String
identifier) [0x00000] in :0 at
TestApp.StartScreenViewController.m__1 (System.Object
sender, System.EventArgs e) [0x0000c] in
/Users/xxx/Projects/TestApp/TestApp/TestApp/StartScreenViewController.cs:57
at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in
:0 at at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication:UIApplicationMain
(int,string[],intptr,intptr) at MonoTouch.UIKit.UIApplication.Main
(System.String[] args, System.String principalClassName, System.String
delegateClassName) [0x00000] in :0 at
TestApp.Application.Main (System.String[] args) [0x00008] in
/Users/xxx/Projects/TestApp/TestApp/TestApp/Main.cs:17
Try:
Hmm, now I added a new UITableViewController to the storyboard, changed some classes to public, changed variable names to starting with lower case. Also the old UITableviewController had a problem with an added SearchController. Now I made everything new and the problem only relied in the viewDidLoad but that was not the original problem. It was one of these steps (perhaps the SearchController problem).
Problematic Code:
this.NavigationController.ToolbarHidden = false;
It seems that he can't find the NavigationController ... How do I addd the navigation controller to the new created view?