Search code examples
xamarinmvvmxamarin.formsmvvmcrossxamarin.uwp

Error UWP with mvvmcross + xamarin forms


I,m trying to navigate to another view in a xamarin forms + mvvmcross with

public ICommand GoCommand
   {
       get
       {
           return new MvxCommand(() => ShowViewModel<SecondViewModel>());
       }
   }

Android works fine, but UWP crash ("Error HRESULT E_FAIL has been returned from a call to a COM component") in Show method:

public async void Show(MvxViewModelRequest request)
   {
       if (await this.TryShowPage(request))
       {
           return;
       }

       Mvx.Error("Skipping request for {0}", request.ViewModelType.Name);
   }

Any idea?? Thanks in advance!


Solution

  • Great!!, I've already seen my mistake. I needed to add this code

           var start = Mvx.Resolve<IMvxAppStart>();
           start.Start();
    

    Method result:

       public MainPage()
        {
            this.InitializeComponent();
    
            var start = Mvx.Resolve<IMvxAppStart>();
    
            start.Start();
    
            MvxFormsWindowsUniversalViewPresenter presenter = Mvx.Resolve<IMvxViewPresenter>() as MvxFormsWindowsUniversalViewPresenter;
    
            if (presenter == null) 
            {
                return;
            }
    
            this.LoadApplication(presenter.XamarinFormsApp);
        }