mvx:警告:遮罩的异常ArgumentException:已经添加了具有相同键的项 [英] mvx:Warning: Exception masked ArgumentException: An item with the same key has already been added

查看:57
本文介绍了mvx:警告:遮罩的异常ArgumentException:已经添加了具有相同键的项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将现有的Xamarin.Android应用程序从mvvmcross 3.5升级到mvvmcross 4.4.0.我遵循了此文档,该应用现在已构建并开始显示启动画面,但它不会越过初始屏幕.当我呼叫ShowViewModel<MainViewModel>()时,什么都没有发生.我看到的最后一个Application输出是下面的输出.我目前不知道下一步要去哪里.有人有主意吗?

I am trying to upgrade an existing Xamarin.Android app from mvvmcross 3.5 to mvvmcross 4.4.0. I have followed this documentation and the app now builds and starts up showing the splashscreen, but it doesn't navigate past the splash screen. When I call ShowViewModel<MainViewModel>() nothing happens. The last Application output I see is the output below. I have currently no idea where to look next. Anybody have an idea?

    mvx:Warning: 17,87 Exception masked ArgumentException: An item with the same key has already been added.
      at System.ThrowHelper.ThrowArgumentException (System.ExceptionResource resource) [0x0000b] in <5d9d5f6570654147b240b9398d8953cc>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (TKey key, TValue value, System.Boolean add) [0x0008e] in <5d9d5f6570654147b240b9398d8953cc>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <5d9d5f6570654147b240b9398d8953cc>:0 
  at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] keySelector, System.Func`2[T,TResult] elementSelector, System.Collections.Generic.IEqualityComparer`1[T] comparer) [0x0005c] in <1a5e8b31a0e44a97a3b8f85920b2d059>:0 
  at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] keySelector, System.Func`2[T,TResult] elementSelector) [0x00000] in <1a5e8b31a0e44a97a3b8f85920b2d059>:0 
  at MvvmCross.Droid.Shared.Presenter.FragmentHostRegistrationSettings.InitializeIfNeeded () [0x00128] in <90641336d9534da69c6ac9e0919ad635>:0 
  at MvvmCross.Droid.Shared.Presenter.FragmentHostRegistrationSettings.IsTypeRegisteredAsFragment (System.Type viewModelType) [0x00000] in <90641336d9534da69c6ac9e0919ad635>:0 
  at MvvmCross.Droid.Shared.Presenter.MvxFragmentsPresenter.Show (MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x0000c] in <90641336d9534da69c6ac9e0919ad635>:0 
  at MvvmCross.Droid.Views.MvxAndroidViewDispatcher+<>c__DisplayClass2_0.<ShowViewModel>b__0 () [0x00000] in <f6aebf863dc84be7b380cfec8d459508>:0 
  at MvvmCross.Droid.Views.MvxAndroidMainThreadDispatcher.RequestMainThreadAction (System.Action action) [0x00019] in <f6aebf863dc84be7b380cfec8d459508>:0 
  at MvvmCross.Droid.Views.MvxAndroidViewDispatcher.ShowViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request) [0x00014] in <f6aebf863dc84be7b380cfec8d459508>:0 
  at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModelImpl (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle, MvvmCross.Core.ViewModels.MvxRequestedBy requestedBy) [0x0002e] in <69bce0378e8e413982d3b552d7e387a8>:0 
  at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModel (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle, MvvmCross.Core.ViewModels.MvxRequestedBy requestedBy) [0x00000] in <69bce0378e8e413982d3b552d7e387a8>:0 
  at MvvmCross.Core.ViewModels.MvxNavigatingObject.ShowViewModel[TViewModel] (MvvmCross.Core.ViewModels.IMvxBundle parameterBundle, MvvmCross.Core.ViewModels.IMvxBundle presentationBundle, MvvmCross.Core.ViewModels.MvxRequestedBy requestedBy) [0x00000] in <69bce0378e8e413982d3b552d7e387a8>:0 
  at MvvmCross.Core.ViewModels.MvxAppStart`1[TViewModel].Start (System.Object hint) [0x00013] in <69bce0378e8e413982d3b552d7e387a8>:0 
  at MvvmCross.Droid.Views.MvxSplashScreenActivity.TriggerFirstNavigate () [0x00005] in <f6aebf863dc84be7b380cfec8d459508>:0 
  at MvvmCross.Droid.Views.MvxSplashScreenActivity.InitializationComplete () [0x00009] in <f6aebf863dc84be7b380cfec8d459508>:0 
  at MvvmCross.Droid.Platform.MvxAndroidSetupSingleton.<InitializeFromSplashScreen>b__7_1 () [0x0000a] in <f6aebf863dc84be7b380cfec8d459508>:0 
  at MvvmCross.Platform.Core.MvxMainThreadDispatcher.ExceptionMaskedAction (System.Action action) [0x00000] in D:\git\MvvmCross\MvvmCross\Platform\Platform\Core\MvxMainThreadDispatcher.cs:22 

推荐答案

问题在于,在升级到MvvmCross 4之前,我们在Setup.cs中拥有自己的protected override IMvxAndroidViewPresenter CreateViewPresenter ()实现.升级后,我们将此实现更改为(标准)实现:

The problem was that before upgrading to MvvmCross 4 we had our own implementation of protected override IMvxAndroidViewPresenter CreateViewPresenter () in Setup.cs. After upgrading we changed this implementation to the (standard) implementation:

    protected override IMvxAndroidViewPresenter CreateViewPresenter()
    {
        var mvxFragmentsPresenter = new MvxFragmentsPresenter(AndroidViewAssemblies);
        Mvx.RegisterSingleton<IMvxAndroidViewPresenter>(mvxFragmentsPresenter);
        return mvxFragmentsPresenter;
    }

标准实现与我们的protected override IList<Assembly> AndroidViewAssemblies实现不兼容.

The standard implementation didn't work wel with our protected override IList<Assembly> AndroidViewAssemblies implementation.

解决方案:

删除protected override IList<Assembly> AndroidViewAssemblies { ... }中的assemblies.Add (typeof(...).Assembly);解决了我们的问题.

Removing assemblies.Add (typeof(...).Assembly); in protected override IList<Assembly> AndroidViewAssemblies { ... } solved our problem.

这篇关于mvx:警告:遮罩的异常ArgumentException:已经添加了具有相同键的项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆