I have a problem with the navigation of my iOS app developed using Xamarin.
On any single view in my app, when I used at least one time the back button and popped a view controller, I may have to deal with this System.InvalidCastException on my main class :
Unable to cast object of type 'App.iOS.UI.PhotoTaker.PhotoTakerViewController' (Objective-C type: 'WorkZoneSelectorViewController') to type 'App.iOS.UI.WorkZoneSelector.WorkZoneSelectorViewController'. Additional information: Selector: viewDidLoad Method: App.iOS.UI.WorkZoneSelector.WorkZoneSelectorViewController:ViewDidLoad ()
In this example, I was on a PhotoTakerViewController and used a PopToRootViewController to go back succesfully to the HomeViewController (this can also happen when I use the "back" button until I'm back on the HomeViewController). Then I tried to use a segWorkZoneSelector to display a WorkZoneViewController. This is where this error appeared. So, for a reason I don't understand, the app try to cast the last view controller I have loaded to the view controller I want to display right now. PhotoTakerViewController and WorkZone inherits from a common AppViewController. None of these 3 classes have an ExportAttribute
I'm not able to reproduce this error systematically.
Something odd with this error message is also the fact that it says that the app crashed on the method WorkZoneSelectorViewController:ViewDidLoad. But when I try to add some instructions at the beginning of the method, these are never called.