This project has moved. For the latest updates, please go here.

Crash at UWP Release Config/ .NetNative

Jan 24, 2016 at 9:03 AM
Edited Jan 24, 2016 at 9:07 AM
Hi,

I am using XAML Map Control in my App to show a Map Control and paint polygones onto it.

If I compile the App in Debug-Config everything works fine, but in Release Config or after Adding .NetNative the App crashes if it shows an polygon and the user zooms to max zoom level.
The Problem is only on UWP / Windows 10.
Windows 8.1 and WP 8.1 is working perfect with same code.
Any Ideas where the problem could be?

Many thanks

Here a little bit from the code:
 <Map:Map x:Name="MapControl" ZoomLevel="17" MinZoomLevel="16" MaxZoomLevel="19">
                    <Map:Map.Center>
                        <Map:Location Latitude="48.333301" Longitude="10.897282"/>
                    </Map:Map.Center>
                    <Map:Map.TileLayer>
                        <Map:TileLayer SourceName="OpenStreetMap"
                           Description="Maps © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)"
                           MaxZoomLevel="18" MinZoomLevel="16" MaxParallelDownloads="1">
                            <Map:TileSource UriFormat="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
                        </Map:TileLayer>
                    </Map:Map.TileLayer>
                </Map:Map>
 try
            {
                //Center and Zoom Map
                Double Lat = Double.Parse((Gebaude.gps.Split(','))[0], System.Globalization.CultureInfo.InvariantCulture);
                Double Long = Double.Parse((Gebaude.gps.Split(','))[1], System.Globalization.CultureInfo.InvariantCulture);
                Location CenterPos = new Location(Lat, Long);
                //AddPolygon:
                try
                {
                    Map.Children.Remove(Map.Children.First(x => x.GetType() == typeof(MapPolyline)));
                }
                catch { }
                MapPolyline Polygone = new MapPolyline();
                String[] Umriss = Gebaude.umriss.Split(';');
                List<Location> Umrissliste = new List<Location>();
                foreach (String s in Umriss)
                {
                    try
                    {
                        Double Lati = Double.Parse((s.Split(','))[0], System.Globalization.CultureInfo.InvariantCulture);
                        Double Longi = Double.Parse((s.Split(','))[1], System.Globalization.CultureInfo.InvariantCulture);

                        Umrissliste.Add(new Location(Lati, Longi));
                    }
                    catch { }
                }
                Polygone.Locations = Umrissliste;
                try
                {
                    Polygone.IsClosed = true;
                    Polygone.Fill = (SolidColorBrush)App.Current.Resources["ForderColor"];
                    Polygone.Stroke = (SolidColorBrush)App.Current.Resources["ForderColor"];
                    Polygone.FillRule = FillRule.EvenOdd;
                    Polygone.StrokeThickness = 1;
                }
                catch
                {
                }

                //Polygone.ZIndex = 0;
                Map.Children.Add(Polygone);

                ProgrammicallyModifyMap = true;
                Map.Center = CenterPos;
                Map.TargetZoomLevel = 17;
            }
            catch { }
Coordinator
Jan 24, 2016 at 11:58 AM
Edited Jan 24, 2016 at 11:59 AM
No idea, the UWP sample application runs with Release/.NET Native build (at least on my system).

But as a general rule, remove all your empty catch blocks!
Jan 24, 2016 at 1:14 PM
Thank you for the tipp,
I have done so.

I think I found the problem after changing the Line
Map.TargetZoomLevel = 17;
to
Map.ZoomLevel = 17;

I could not recognize any crash until now.
Coordinator
Jan 24, 2016 at 2:24 PM
There is no reason why setting TargetZoomLevel shouldn't work in a UWP app with Release/.NET Native build.
Jan 24, 2016 at 2:36 PM
Edited Jan 24, 2016 at 2:39 PM
I don't think there is a bug in TargetZoomLevel but I think the bug is in .Net Native, because I had some trouble with another app too.
It is since November Update (SDK 1.2).
Doing much work at the same time seems to throw an "Invalid Operation Exception", but I could not get more Information until now.

PS: If there is no polyline on the Map, the App also does not crash with using TargetZoomLevel.