Bug 43098 - MapView crashing on iOS 10 beta
Summary: MapView crashing on iOS 10 beta
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.99 (iOS 10 previews)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2016-08-05 16:49 UTC by jmelliadis
Modified: 2016-08-05 19:36 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description jmelliadis 2016-08-05 16:49:36 UTC
I have an app that uses an extended version of the Xamarin.Forms.Maps mapview on iOS. Users on iOS 10 are crashing with the following exception when going to the map page:

System.InvalidCastExceptionSpecified cast is not valid.

iSurvey.iOS.ExtendedMapView_iOS.<OnElementPropertyChanged>m__0(MKMapView mapView, IMKAnnotation annotation)
<Module>.invoke_MKAnnotationView_MKMapView_IMKAnnotation(MKMapView, IMKAnnotation)(wrapper delegate-invoke)
MapKit.MKMapView._MKMapViewDelegate.GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
UIKit.UIApplication.UIApplicationMain(int, string[], intptr, intptr)(wrapper managed-to-native)
UIKit.UIApplication.Main(string[] args, IntPtr principal, IntPtr delegate)
UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName)
iSurvey.iOS.Application.Main(string[] args)

It appears it is crashing when I try to cast the IMKAnnotation to my custom map annotation class (which extends the MKAnnotation class). This cast is working fine on all versions before iOS 10.
Comment 1 jmelliadis 2016-08-05 19:36:26 UTC
I have fixed this issue by using Runtime.GetNSObject() to get the native object before trying to cast to my custom map annotation.