2017-03-01 1 views
2

My Android App se bloque dans l'environnement de production, notre outil de reporting crash est XamarinInsights, il retourne la pile suivanten'a pas réussi à résoudre paramètre pour répartiteur de paramètre de type IMvxMainThreadDispatcher lors de la création

at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.GetIoCParameterValues (System.Type type, System.Reflection.ConstructorInfo firstConstructor) [0x00066] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type) [0x0002a] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.Mvx.IocConstruct[T]() [0x00005] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.Mvx+<>c__13`2[TInterface,TType].<LazyConstructAndRegisterSingleton>b__13_0() [0x00000] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer+<>c__DisplayClass33_0`1[TInterface].<RegisterSingleton>b__0() [0x00000] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer+ConstructingSingletonResolver.Resolve() [0x00028] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.InternalTryResolve (System.Type type, MvvmCross.Platform.IoC.MvxSimpleIoCContainer+IResolver resolver, System.Object& resolved) [0x00041] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.InternalTryResolve (System.Type type, System.Nullable`1[T] requiredResolverType, System.Object& resolved) [0x0002e] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.InternalTryResolve (System.Type type, System.Object& resolved) [0x00000] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.Resolve (System.Type t) [0x00011] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.Resolve[T]() [0x00000] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MvvmCross.Platform.Mvx.Resolve[TService]() [0x00005] in <4ddde23419c5494288c799fcdbb0f189>:0 
at MyNamespace.Android.PushNotificationListener.SendNotification (System.String message, MyNamespace.Core.NotificationPayload payload) [0x00137] in <03e2d64cacc54ebebbfb6133dd9c33ae>:0 

Je pense exception a été levée lorsque J'essaie de résoudre et de construire MainThreadDispatcher. Mais je ne peux pas comprendre pourquoi.

private IMvxMainThreadDispatcher _dispatcher = Mvx.Resolve<IMvxMainThreadDispatcher>(); 

    private void ShowToastMessage(string message, double duration) 
    { 
      _dispatcher.RequestMainThreadAction(() => 
      { 
       ... 
      }); 
    } 

Répondre

2

Essayez d'initialiser le système MvvmCross chaque fois que vous recevez un coup de pouce parce que l'exécution pourrait être fait dans un contexte différent (lorsque l'application est déchargé), mais le service de notification push est active.

MvvmCross initialization

2

Ceci est un problème assez fréquent lorsque vous travaillez avec IntentService ou BroadcastReceiver après que le processus a été redémarré. Le conteneur MvvmCross IoC est normalement configuré par votre écran de démarrage. L'écran de démarrage n'est pas affiché dans ces cas, donc le Mvx IoC est fondamentalement non initialisé. Vous pouvez résoudre le problème en vous assurant que l'installation de MvvmCross est initialisée après avoir reçu la notification push.

var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this.ApplicationContext); 
setupSingleton.EnsureInitialized(); 

MvvmCross a MvxIntentService et MvxBroadcastReceiver. Si vous utilisez ces objets, l'installation de MvvmCross est automatiquement initialisée pour vous.