Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MvvmCross.Forms cannot replace app's MainPage #2577

Closed
2 of 7 tasks
vkonst86 opened this issue Feb 1, 2018 · 6 comments
Closed
2 of 7 tasks

MvvmCross.Forms cannot replace app's MainPage #2577

vkonst86 opened this issue Feb 1, 2018 · 6 comments
Assignees
Labels
p/forms Xamarin.Forms platform s/needs-investigation Needs investigation by the MvvmCross team t/bug Bug type
Milestone

Comments

@vkonst86
Copy link

vkonst86 commented Feb 1, 2018

Steps to reproduce 📜

  1. Create an app with root page that is content or navigation page. Add additional page to project with type of MvxTabbedPage and attribute [MvxTabbedPagePresentation(Position = TabbedPosition.Root, WrapInNavigationPage = false)]

  2. When root view is loaded try navigate to tabbed page using IMvxNavigatingService.Navigate and await the call, app will crash with exception "Cannot replace MainPage".

  3. The reason of the crash is that MvxFormsApplicationDelegate method FinishedLaunching is not calling base.FinishedLaunching, so FormsApplicationDelegate private field "_window" is not initialised, and app crashes at method UpdateMainPage of FormsApplicationDelegate.

Expected behavior 🤔

MainPage gets replaced

Actual behavior 🐛

App crash

Configuration 🔧

Version: 5.6.x

Platform:

  • 📱 iOS
  • 🤖 Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • 📺 tvOS
  • 🐒 Xamarin.Forms
@gunjanddave
Copy link

Facing the same issue. Any fix ?

@vkonst86
Copy link
Author

I'm using workaround for now.
private void InitializeInternalWindow(UIWindow window) { var windowField = typeof(FormsApplicationDelegate).GetField("_window", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); windowField.SetValue(this, window); }
Call this method in FinishedLaunching after you created UIWindow, and pass it there.

@gunjanddave
Copy link

@vkonst86 - Thanks. Your workaround works like charm.

@martijn00 martijn00 added p/forms Xamarin.Forms platform t/bug Bug type labels Mar 21, 2018
@martijn00 martijn00 added this to the 6.0.0 milestone Mar 21, 2018
@nickrandolph
Copy link
Contributor

@vkonst86 are you able to reproduce this in the playground sample? If so, can you submit a PR with your changes showing how to reproduce the issue

@nickrandolph nickrandolph added the s/needs-investigation Needs investigation by the MvvmCross team label Mar 26, 2018
@martijn00
Copy link
Contributor

This is fixed in the playground.

@tampham1210
Copy link

@martijn00 can you add the reference source code over here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/forms Xamarin.Forms platform s/needs-investigation Needs investigation by the MvvmCross team t/bug Bug type
Development

No branches or pull requests

5 participants