Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

MvvmCross Initializing IoC Throws MvxIoCResolveException

$
0
0

I've just upgraded an MvvmCross project from 6.3.1 to 6.4.1. One of the things this update did was change the return type of MvxFormsAndroidSetup.InitializeIoc() from void to IMvxIocProvider. So, to get the right return type, I re-wrote my method like this:

        protected override IMvxIoCProvider InitializeIoC()
        {
            base.InitializeIoC();

            var androidIoCContainer = Mvx.IoCProvider.CreateChildContainer();
            androidIoCContainer.RegisterSingleton(() => UserDialogs.Instance);
            androidIoCContainer.RegisterSingleton(() => CrossSettings.Current);
            androidIoCContainer.RegisterSingleton(() => CrossPermissions.Current);

            return androidIoCContainer;
        }

This builds, but throws an MvxIoCREsolveException on base.OnCreate() in MainActivity.cs: 'Failed to resolve type MvvmCross.Logging.IMvxLogProvider'.

Anyone know how to fix this? I'm guessing that by creating a ChildContainer in InitializeIoc(), I've created some conflict between different references to the IMvxLogProvider, but I'm still fairly new to MvvmCross, so I'm not sure how to proceed.

Here's the stack trace, if you're interested:

  at MvvmCross.IoC.MvxIoCContainer.Resolve (System.Type t) [0x0001c] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:252 
  at MvvmCross.IoC.MvxIoCContainer.Resolve[T] () [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:242 
  at MvvmCross.IoC.MvxIoCProvider.Resolve[T] () [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCProvider.cs:66 
  at MvvmCross.Core.MvxSetup.CreateLogProvider () [0x00000] in D:\a\1\s\MvvmCross\Core\MvxSetup.cs:329 
  at MvvmCross.Core.MvxSetup.InitializeLoggingServices () [0x00000] in D:\a\1\s\MvvmCross\Core\MvxSetup.cs:277 
  at MvvmCross.Core.MvxSetup.InitializePrimary () [0x0002f] in D:\a\1\s\MvvmCross\Core\MvxSetup.cs:79 
  at MvvmCross.Core.MvxSetupSingleton.StartSetupInitialization () [0x0000a] in D:\a\1\s\MvvmCross\Core\MvxSetupSingleton.cs:181 
  at MvvmCross.Core.MvxSetupSingleton.EnsureInitialized () [0x00017] in D:\a\1\s\MvvmCross\Core\MvxSetupSingleton.cs:102 
  at MvvmCross.Forms.Platforms.Android.Views.MvxFormsAppCompatActivity.OnCreate (Android.OS.Bundle bundle) [0x0000c] in D:\a\1\s\MvvmCross.Forms\Platforms\Android\Views\MvxFormsAppCompatActivity.cs:105 
  at SDA.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00017] in C:\Users\shodg\SDA\SDA\SDA.Android\MainActivity.cs:17 
  at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.17(intptr,intptr,intptr)

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>