MVVX Failed to initialize ViewModel from MvxDefaultViewModelLocator - c#

I am trying to create a mobile application using MVVX.
get below error when trying to run the Droid application.
MvvmCross.Platform.Exceptions.MvxException: Failed to construct and initialize ViewModel for type ThoughtOfTheDay.ViewModels.LoginViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information
Below is the detail of inner exception.
MvvmCross.Platform.Exceptions.MvxException: Failed to construct and initialize ViewModel for type ThoughtOfTheDay.ViewModels.LoginViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information ---> MvvmCross.Platform.Exceptions.MvxException: Problem creating viewModel of type LoginViewModel ---> MvvmCross.Platform.Exceptions.MvxIoCResolveException: Failed to resolve parameter for parameter messenger of type IMvxMessenger when creating ThoughtOfTheDay.ViewModels.LoginViewModel
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.GetIoCParameterValues (System.Type type, System.Reflection.ConstructorInfo firstConstructor) [0x00036] in D:\git\MvvmCross\MvvmCross\Platform\Platform\IoC\MvxSimpleIoCContainer.cs:504
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type) [0x0002a] in D:\git\MvvmCross\MvvmCross\Platform\Platform\IoC\MvxSimpleIoCContainer.cs:314
at MvvmCross.Platform.Mvx.IocConstruct (System.Type t) [0x00005] in D:\git\MvvmCross\MvvmCross\Platform\Platform\Mvx.cs:170
at MvvmCross.Core.ViewModels.MvxDefaultViewModelLocator.Load (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterValues, MvvmCross.Core.ViewModels.IMvxBundle savedState) [0x00000] in <69bce0378e8e413982d3b552d7e387a8>:0
--- End of inner exception stack trace ---
at MvvmCross.Core.ViewModels.MvxDefaultViewModelLocator.Load (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterValues, MvvmCross.Core.ViewModels.IMvxBundle savedState) [0x00027] in <69bce0378e8e413982d3b552d7e387a8>:0
at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState, MvvmCross.Core.ViewModels.IMvxViewModelLocator viewModelLocator) [0x00015] in <69bce0378e8e413982d3b552d7e387a8>:0
--- End of inner exception stack trace ---
at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState, MvvmCross.Core.ViewModels.IMvxViewModelLocator viewModelLocator) [0x00046] in <69bce0378e8e413982d3b552d7e387a8>:0
at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState) [0x00020] in <69bce0378e8e413982d3b552d7e387a8>:0
at MvvmCross.Droid.Views.MvxAndroidViewsContainer.ViewModelFromRequest (MvvmCross.Core.ViewModels.MvxViewModelRequest viewModelRequest, MvvmCross.Core.ViewModels.IMvxBundle savedState) [0x00005] in :0
at MvvmCross.Droid.Views.MvxAndroidViewsContainer.CreateViewModelFromIntent (Android.Content.Intent intent, MvvmCross.Core.ViewModels.IMvxBundle savedState) [0x00027] in :0
at MvvmCross.Droid.Views.MvxAndroidViewsContainer.Load (Android.Content.Intent intent, MvvmCross.Core.ViewModels.IMvxBundle savedState, System.Type viewModelTypeHint) [0x00089] in :0
at MvvmCross.Droid.Views.MvxActivityViewExtensions.LoadViewModel (MvvmCross.Droid.Views.IMvxAndroidView androidView, MvvmCross.Core.ViewModels.IMvxBundle savedState) [0x0006a] in :0
at MvvmCross.Droid.Views.MvxActivityViewExtensions+<>c__DisplayClass1_0.b__1 () [0x0000a] in :0
at MvvmCross.Core.Views.MvxViewExtensionMethods.OnViewCreate (MvvmCross.Core.Views.IMvxView view, System.Func1[TResult] viewModelLoader) [0x00012] in <69bce0378e8e413982d3b552d7e387a8>:0
at MvvmCross.Droid.Views.MvxActivityViewExtensions.OnViewCreate (MvvmCross.Droid.Views.IMvxAndroidView androidView, Android.OS.Bundle bundle) [0x00062] in <f6aebf863dc84be7b380cfec8d459508>:0
at MvvmCross.Droid.Views.MvxActivityAdapter.EventSourceOnCreateCalled (System.Object sender, MvvmCross.Platform.Core.MvxValueEventArgs1[T] eventArgs) [0x0000c] in :0
at (wrapper delegate-invoke) System.EventHandler1[MvvmCross.Platform.Core.MvxValueEventArgs1[Android.OS.Bundle]]:invoke_void_object_TEventArgs (object,MvvmCross.Platform.Core.MvxValueEventArgs1<Android.OS.Bundle>)
at MvvmCross.Platform.Core.MvxDelegateExtensionMethods.Raise[T] (System.EventHandler1[TEventArgs] eventHandler, System.Object sender, T value) [0x00000] in D:\git\MvvmCross\MvvmCross\Platform\Platform\Core\MvxDelegateExtensionMethods.cs:21
at MvvmCross.Platform.Droid.Views.MvxEventSourceActivity.OnCreate (Android.OS.Bundle bundle) [0x00014] in <4230cf00b647458f9b3e211590e6cc9d>:0
at ThoughtOfTheDay.Droid.Views.LoginView.OnCreate (Android.OS.Bundle bundle) [0x00002] in C:\Work\MobileDev\ThoughtOfTheDay\ThoughtOfTheDay\ThoughtOfTheDay.Droid\Views\LoginView.cs:15
I am trying to pass IMvxMessenger to the view model. Inner exception message above shows there is a problem resolving IMvxMessenger. Do I need to include something for it in the app.cs\Initialize() ? Let me know if you need more info. Thanks a lot for your time and help.
public LoginViewModel(IMvxMessenger messenger,
IDialogService dialogService,
IUserService userService)
: base(messenger)
{
_userService = userService;
_dialogService = dialogService;
}
Solution: Installed Nuget package for MvvmCross.Plugin.Messenger in the Android project as well.
Earlier I had it installed only in the PCL project.

Solution: Installed Nuget package for MvvmCross.Plugin.Messenger in the Android project as well. Earlier I had it installed only in the PCL project.

Sounds like you are missing the bootstrap for the plugin.
Make sure a class inside of the Bootstrap folder has been made with the following contents:
using MvvmCross.Platform.Plugins;
namespace your.name.space.Bootstrap
{
public class MessengerPluginBootstrap
: MvxPluginBootstrapAction<MvvmCross.Plugins.Messenger.PluginLoader>
{
}
}
This will register the plugin with the IoC container.
Alternatively you can register it yourself in InitializeLastChance in your Setup.cs file:
Mvx.RegisterSingleton<IMvxMessenger>(() => new MvxMessengerHub());

Related

ConfigurationErrorsException

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>

Can't open script file in Mono Develop after update unity

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

Using Realm in Xamarin.Android app running in emulator throws RealmFileAccessErrorException

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.

System.Reflection.TargetInvocationException thrown when trying to instantiate new ViewController

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?

Android NoSuchMethodError being thrown on ArrayAdapter Constructor

I'm attempting to extend the generic ArrayAdapter in order to customize a ListView and am getting an NoSuchMethodError being thrown when I hit the TpAdapter (my extended Adapter) constructor
Here is the exteded ArrayAdapter TpAdapter
private class TpAdapter : ArrayAdapter<MobileTalkingPoint>
{
private MobileTalkingPoint[] items;
private Context outer_context;
public TpAdapter(Context context, int textViewResourceId, MobileTalkingPoint[] items)
: base(context, textViewResourceId, items)
{
this.items = items;
this.outer_context = context;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)outer_context.GetSystemService(Context.LayoutInflaterService);
v = vi.Inflate(Resource.Layout.ItemTalkingPoint, null);
}
MobileTalkingPoint tp = items[position];
if (tp != null)
{
TextView tpDate = v.FindViewById<TextView>(Resource.Id.tpDate);
TextView tpTitle = v.FindViewById<TextView>(Resource.Id.tpTitle);
TextView tpType = v.FindViewById<TextView>(Resource.Id.tpType);
TextView tpBody = v.FindViewById<TextView>(Resource.Id.tpBody);
tpDate.Text = String.Format("{0:MM/dd/yy}", tp.TPDate);
tpTitle.Text = tp.Title;
tpType.Text = tp.Type;
tpBody.Text = tp.Descr;
}
return v;
}
}
I am instantiating them as follows in the activity:
MobileTalkingPoint[] weaknesses = talkingPoints;
TpAdapter adapStrength = new TpAdapter(this, Resource.Layout.ItemTalkingPoint, strengths);
And the stacktrace for the exception is as follows
I/ActivityManager( 1283): Starting: Intent { cmp=MapDroid.MapDroid/mapdroid.TabbedView (has extras) } from pid 22409
I/ActivityManager( 1283): Displayed MapDroid.MapDroid/mapdroid.TabbedView: +573ms
D/dalvikvm(22409): GetMethodID: method not found: Lmapdroid/TabTalkingPoints_TpAdapter;.<init>:(Landroid/content/Context;I[Ljava/lang/Object;)V
I/MonoDroid(22409): UNHANDLED EXCEPTION: Java.Lang.NoSuchMethodError: Exception of type 'Java.Lang.NoSuchMethodError' was thrown.
I/MonoDroid(22409): at Android.Runtime.JNIEnv.GetMethodID (intptr,string,string) <0x0007c>
I/MonoDroid(22409): at Android.Widget.ArrayAdapter`1<MonoMap.wsMobile.MobileTalkingPoint>..ctor (Android.Content.Context,int,MonoMap.wsMobile.MobileTalkingPoint[]) <0x0027b>
I/MonoDroid(22409): at MapDroid.TabTalkingPoints/TpAdapter..ctor (Android.Content.Context,int,MonoMap.wsMobile.MobileTalkingPoint[]) <0x0002b>
I/MonoDroid(22409): at MapDroid.TabTalkingPoints.ShowList () <0x00077>
I/MonoDroid(22409): at MapDroid.TabTalkingPoints.OnCreate (Android.OS.Bundle) <0x001df>
I/MonoDroid(22409): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00057>
I/MonoDroid(22409): at (wrapper dynamic-method) object.b1cd4072-05f5-4443-8835-b4102b462c1e (intptr,intptr,intptr) <0x00033>
I/MonoDroid(22409):
I/MonoDroid(22409): --- End of managed exception stack trace ---
I/MonoDroid(22409): java.lang.NoSuchMethodError: <init>
I/MonoDroid(22409): at mapdroid.TabTalkingPoints.n_onCreate(Native Method)
I/MonoDroid(22409): at mapdroid.TabTalkingPoints.onCreate(TabTalkingPoints.java:25)
I/MonoDroid(22409): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
I/MonoDroid(22409): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
I/MonoDroid(22409): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1598)
I/MonoDroid(22409): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
I/MonoDroid(22409): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
I/MonoDroid(22409): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
I/MonoDroid(22409): at android.widget.TabHost.setCurrentTab(TabHost.java:326)
I/MonoDroid(22409): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132)
I/MonoDroid(22409): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:455)
I/MonoDroid(22409): at android.view.View.performClick(View.java:2501)
I/MonoDroid(22409): at android.view.View$PerformClick.run(View.java:9107)
I/MonoDroid(22409): at android.os.Handler.handleCallback(Handler.java:587)
I/MonoDroid(22409): at android.os.Handler.dispatchMessage(Handler.java:92)
I/MonoDroid(22409): at android.os.Looper.loop(Looper.java:123)
I/MonoDroid(22409): at android.app.ActivityThread.main(ActivityThread.java:3835)
I/MonoDroid(22409): at java.lang.reflect.Method.invokeNative(Native Method)
I/MonoDroid(22409): at java.lang.reflect.Method.invoke(Method.java:507)
I/MonoDroid(22409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
I/MonoDroid(22409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
I/MonoDroid(22409): at dalvik.system.NativeStart.main(Native Method)
E/mono (22409):
E/mono (22409): Unhandled Exception: Java.Lang.NoSuchMethodError: Exception of type 'Java.Lang.NoSuchMethodError' was thrown.
E/mono (22409): at Android.Runtime.JNIEnv.GetMethodID (IntPtr kls, System.String name, System.String signature) [0x00000] in <filename unknown>:0
E/mono (22409): at Android.Widget.ArrayAdapter`1[MonoMap.wsMobile.MobileTalkingPoint]..ctor (Android.Content.Context context, Int32 textViewResourceId, MonoMap.wsMobile.MobileTalkingPoint[] objects) [0x00000] in <filename unknown>:0
E/mono (22409): at MapDroid.TabTalkingPoints+TpAdapter..ctor (Android.Content.Context context, Int32 textViewResourceId, MonoMap.wsMobile.MobileTalkingPoint[] items) [0x00000] in <filename unknown>:0
E/mono (22409): at MapDroid.TabTalkingPoints.ShowList () [0x00000] in <filename unknown>:0
E/mono (22409): at MapDroid.TabTalkingPoints.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
E/mono (22409): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0
E/mono (22409): at (wrapper dynamic-method)
I/ActivityManager( 1283): Process MapDroid.MapDroid (pid 22409) has died.
NOTE I am using Mono for Android with Visual Studio 2010
I'm not sure if this is a bug in Mono For Android or not (seems like it might be, though), but if you modify your adapter to take in an IList instead of an array, the problem goes away:
private class TpAdapter : ArrayAdapter<MobileTalkingPoint>
{
public TpAdapter(Context context, int textViewResourceId, IList<MobileTalkingPoint> items)
: base(context, textViewResourceId, items)
{
}
}
You can still call it using an array, so that doesn't need to be modified:
MobileTalkingPoint[] points = { };
TpAdapter adapStrength = new TpAdapter(this, Resource.Layout.ItemTalkingPoint, points);

Categories

Resources