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?
Related
I am getting an exception I have no clue how to debug. It is thrown on the following line:
var serializer = new XmlSerializer(typeof(Universe));
System.Configuration.ConfigurationErrorsException has been thrown
Error Initializing the configuration system.
What is the configuration system, where is it getting initialized and what does it have to do with the XmlSerializer?
The full exception:
System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <runtime> (/MyPath/Projects/Stars/Stars/Stars.Desktop/bin/Debug/net471/Stars.Desktop.app/Contents/MonoBundle/Stars.Desktop.exe.config line 3)
at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/ConfigInfo.cs:77
at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed, System.Boolean root) [0x0011f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/SectionGroupInfo.cs:330
at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, System.Boolean overrideAllowed) [0x00007] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/SectionGroupInfo.cs:273
at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x000ce] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:572
at System.Configuration.Configuration.Load () [0x00043] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:532
at System.Configuration.Configuration.Init (System.Configuration.Internal.IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x0005d] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:138
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00056] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:96
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0000d] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/InternalConfigurationFactory.cs:41
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (System.Configuration.ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x000ea] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:119
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x0000e] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:49
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x0001f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:52
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:61
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:159
at System.Configuration.PrivilegedConfigurationManager.GetSection (System.String sectionName) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/misc/PrivilegedConfigurationManager.cs:24
at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs:171
at System.Diagnostics.DiagnosticsConfiguration.Initialize () [0x0002a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs:209
at System.Diagnostics.DiagnosticsConfiguration.get_SwitchSettings () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs:29
at System.Diagnostics.Switch.InitializeConfigSettings () [0x00013] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/compmod/system/diagnostics/Switch.cs:272
at System.Diagnostics.Switch.InitializeWithStatus () [0x00046] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/compmod/system/diagnostics/Switch.cs:211
at System.Diagnostics.Switch.get_SwitchSetting () [0x0000a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/compmod/system/diagnostics/Switch.cs:144
at System.Diagnostics.BooleanSwitch.get_Enabled () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/compmod/system/diagnostics/BooleanSwitch.cs:39
at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly (System.Type type, System.String defaultNamespace, System.Xml.Serialization.XmlSerializerImplementation& contract) [0x00015] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System.Xml/System/Xml/Serialization/Compilation.cs:164
at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.String defaultNamespace) [0x0007e] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System.Xml/System/Xml/Serialization/XmlSerializer.cs:198
at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System.Xml/System/Xml/Serialization/XmlSerializer.cs:177
at Stars.SaveManager.SaveLoader.SaveUniverse (Stars.Game.Universe universe) [0x0005d] in /MypPath/Projects/Stars/Stars/Stars/SaveManager/SaveLoader.cs:39
You have an error in app.config file. There is a problem with the section runtime. Be sure it is declared in and has valid structure and values.
Here the Inner exception message gives the hint
System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <runtime>
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 am using realm.xamarin 0.75 with xamarin forms and while executing query, i get a weird error. the query is
DateTimeOffset fromOffset = new DateTimeOffset(fromDate);
DateTimeOffset toOffset = new DateTimeOffset(toDate);
var config = DependencyService.Get<IDatabase>().GetConfiguration();
using (var realm = Realm.GetInstance(config))
{
return realm.All<Measurements>()Where(o => o.CreatedDateTime >= fromOffset && o.CreatedDateTime <= toOffset).OrderByDescending(o => o.CreatedDateTime).ToList();
}
And the error is:
UNHANDLED EXCEPTION:
06-06 17:46:15.337 I/MonoDroid(26505): Realms.RealmException: Data type mismatch
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.NativeCommon.ExceptionThrower (NativeException exception) [0x00007] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at (wrapper native-to-managed) Realms.NativeCommon:ExceptionThrower (Realms.NativeException)
06-06 17:46:15.337 I/MonoDroid(26505): at (wrapper managed-to-native) Realms.NativeQuery:timestamp_milliseconds_greater_equal (Realms.QueryHandle,intptr,long)
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResultsVisitor.AddQueryGreaterThanOrEqual (Realms.QueryHandle queryHandle, System.String columnName, System.Object value) [0x000b6] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResultsVisitor.VisitBinary (System.Linq.Expressions.BinaryExpression b) [0x0016c] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x000d2] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResultsVisitor.VisitCombination (System.Linq.Expressions.BinaryExpression b, System.Action`1 combineWith) [0x00012] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResultsVisitor.VisitBinary (System.Linq.Expressions.BinaryExpression b) [0x0000c] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x000d2] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResultsVisitor.VisitMethodCall (System.Linq.Expressions.MethodCallExpression m) [0x0006a] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x000ec] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResultsVisitor.VisitMethodCall (System.Linq.Expressions.MethodCallExpression m) [0x000e6] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x000ec] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResults`1[T].CreateResultsHandle () [0x00037] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResults`1[T].get_ResultsHandle () [0x0000d] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at Realms.RealmResults`1[T].GetEnumerator () [0x00000] in <filename unknown>:0
06-06 17:46:15.337 I/MonoDroid(26505): at System.Collections.Generic.List`1[T]..ctor (IEnumerable`1 collection) [0x00073] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/collections/generic/list.cs:104
06-06 17:46:15.337 I/MonoDroid(26505): at System.Linq.Enumerable.ToList[TSource] (IEnumerable`1 source) [0x00011] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:835
i suscpect DateTimeOffset could be causing the issue.
i checked the source code at https://github.com/realm/realm-dotnet
but couldn't find anything.
I found the issue. It happens when the class for RealmObject(in my case Measurements) is not inheriting directly from RealmObject.
My class Measurements was inheriting from a class BaseModel (i created this class for internal purpose) and this BaseModel class was inheriting from RealmObject.
When i removed this and made Measurements inherit directly from RealmObject, i doesn't throws exception.
From Dimitris Tavlikos 's comment,
Realm Xamarin does not allow models to be further subclassed in any way. The CreateObject generic method only works if you use it for a class which descends directly from RealmObject.
https://realm.io/docs/xamarin/latest/#model-inheritance
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.