Morning.
As the title states on iOS I am getting a NullReferenceException at ThinkGeo.UI.XamarinForms.MapView…ctor. It is working fine on droid.
It is a Xamarin Forms app I am building with both a Droid and iOS projects. I have almost zero code in the platform projects.
The layout of the app is within a Xamarin Forms shell where I have a few pages and one contains your map control. Currently it is simple and very similar to your samples. A few layers with a handful of features.
On Android this has been working very nicely. I have just shifted over to iOS and I am getting the error on the pages init. Very simple page and I do use XAML.
I use the MVVM pattern and I pass the map control into the backing VM.
The xaml is
<ContentPage.Content>
<ThinkGeo:MapView x:Name="mapView"
VerticalOptions="FillAndExpand"
MapLongPress="mapView_MapLongPress" />
</ContentPage.Content>
and the code behind is
public MapPage()
{
InitializeComponent();
MapPageViewModel = new MapPageViewModel(mapView);
BindingContext = MapPageViewModel;
}
The exception raised is on the InitializeComponent(); call.
The inner exception details are: (NOTE: -snip- is me removing stuff not required to be seen)
{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.NullReferenceException: Object reference not set to an instance of an object at ThinkGeo.UI.XamarinForms.MapView…ctor () [0x00030] in <1c709128f19f4e40990c9608d8dcd160>:0 at -snip-.Map.MapPage.InitializeComponent () [0x00023] in -snip-\obj\Debug\netstandard2.0\Map\MapPage.xaml.g.cs:26 at -snip-.Map.MapPage…ctor () [0x0003a] in -snip-\Map\MapPage.xaml.cs:30 at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&) at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:936 — End of inner exception stack trace —
Here are the details of my environment:
I am running it on a sim at iOS 14.4.
Microsoft Visual Studio Professional 2019
Version 16.9.4
VisualStudio.16.Release/16.9.4+31205.134
Microsoft .NET Framework
Version 4.8.04084
Xamarin 16.9.000.273 (d16-9@1bba9e0)
Xamarin.iOS and Xamarin.Mac SDK 14.14.2.5 (3836759d4)
ThinkGeo.UI.XamarinForms.iOS v12.3.10
Forms v4.8.0.1687
Xcode 12.4
I am currently running using an evaluation licence which has many more days before expiry.
I am happy to provide further details if required.
Cheers
Chris …