FYI: we received the following stack trace from our telemetry recently. This was using the .NET Runtime running on iOS, using Xamarin. Hopefully, it helps to fix some bugs that haven't been discovered yet.
This issue has recently been happening on our WPF application in version 100.12. Here is the full stack of the error:
Null pointer: map_point.get_spatial_reference()
at Esri.ArcGISRuntime.ArcGISException.HandleCoreError(CoreError error, Boolean throwException)
at RuntimeCoreNet.GeneratedWrappers.Interop.CheckError(IntPtr errorHandle, Boolean throwOnFailure, GCHandle wrapperHandle)
at RuntimeCoreNet.GeneratedWrappers.CoreMapView.LocationToScreen(CorePoint mapPoint)
at Esri.ArcGISRuntime.UI.Controls.MapView.LocationToScreen(MapPoint location)
at Esri.ArcGISRuntime.UI.Controls.GeoView.<>c__DisplayClass238_0.<ArrangeViewOverlays>b__1(MapPoint p, LocationVisibility& visibility)
at Esri.ArcGISRuntime.UI.Controls.MapOverlayPanel.ArrangeMapOverlayItem(OverlayItem child)
at Esri.ArcGISRuntime.UI.Controls.MapOverlayPanel.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Hello @ahassan3! The stack trace that you shared points to MapView Overlays -- is your application using this feature?
I was able to reproduce this exception by creating a MapView overlay with a ViewOverlayAnchor point that has no SpatialReference. I don't think that should throw -- I am investigating whether this is a bug in Runtime -- but a workaround should be simple. Ensure that your application always sets the SpatialRefrence on the ViewOverlayAnchors.
Please let me know if this helps!
@MatveiStefarov Upon investigating my issue, i am seeing that the mapview has a null spatial reference. What's making it null ? before setting the graphicsoverlay, i am setting the
MapView.map = new Map (SpatialReferences.WebMercator)
Shouldn't this set the mapview's reference. I can subscribe to the spatialreference changed event and check when that becomes null. How can i set the spatialreference once it becomes null.
Setting MapView.Map is the right way to set SpatialReference. In your example, I would expected MapView.SpatialReference property to be set to WebMercator right away.
MapView's SpatialReference can only be null if its Map property is null, or if it's set to a non-loaded/failed-to-load Map object.
Looking through MapOverlayPanel source on our end, I see that a null SpatialReference on the GeoView can indeed cause an exception similar to your stack trace, but only if ViewOverlayAnchor attached property is not set (or set too late). This also seems like a Runtime bug to me, and I'll investigate it.
The workaround for this one would be to ensure that ViewOverlayAnchor property is set before an overlay is added to MapView.
If this still does not solve the problem, could you please share how you use Runtime in more detail?