ThinkGeo.com    |     Documentation    |     Premium Support

KmlLayer: The type initializer for 'xRM=.OxY=' threw an exception

When trying to load a KML file I’m getting the exception above, stack trace below, sample attached Kml Sample.txt (72.8 KB)

at xRM=.OxY=.PhY=(String nodeLocalName)
at ThinkGeo.MapSuite.Core.KmlFile.ReadStyles()
at ThinkGeo.MapSuite.Core.KmlFile.Open()
at ThinkGeo.MapSuite.Core.KmlFeatureSource.OpenCore()
at ThinkGeo.MapSuite.Core.FeatureSource.Open()
at ThinkGeo.MapSuite.Core.FeatureLayer.OpenCore()
at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.Overlay.sRM=(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.dRQ=(IEnumerable`1 drawingOverlays, RectangleShape extent)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.dBQ=(RectangleShape drawingExtent, RectangleShape extent)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.lBQ=(RectangleShape extent)
at ShapefileToGoogleMap.KmlTestForm.OpenKml(String fileName) in C:\Users\sclark.CBO\Documents\Visual Studio 2015\Projects\ThinkGeo\Samples\ShapefileToGoogleMap\KmlTestForm.cs:line 48
at ShapefileToGoogleMap.KmlTestForm.openKmlBtn_Click(Object sender, EventArgs e) in C:\Users\sclark.CBO\Documents\Visual Studio 2015\Projects\ThinkGeo\Samples\ShapefileToGoogleMap\KmlTestForm.cs:line 64

The method is very simple at the moment, it appears it’s something within the style format that’s an issue

private void OpenKml(string fileName)
{
    KmlFeatureLayer layer = new KmlFeatureLayer(fileName);
    layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

    layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Black), new GeoSolidBrush(GeoColor.SimpleColors.Yellow));
    layer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.SimpleColors.Blue, 5));
    layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.SimpleColors.Green), 10);

    LayerOverlay overlay = new LayerOverlay();
    string layerName = System.IO.Path.GetFileNameWithoutExtension(fileName);
    overlay.Layers.Add(layerName, layer);

    string overlayName = $"{layerName}-Overlay";
    winformsMap1.Overlays.Add(overlayName, overlay);

    winformsMap1.Refresh();
}

Hi Sam,

It seems that the kml file is truncated, and I fixed the file’s format but failed to recreated the issue. Could you please send it again?

Thanks,
Peter

Had to upload full file elsewhere because it’s huge, but file located here

And the schema uploaded, see link below
nps_boundary.kml.xml (48.3 KB)

Hi Sam,

Thanks for sharing it again. It works well on my side.

I don’t if something I missed on my side, could you please tell me further information, such as the System information, how to recreate this issue?

Thanks,
Peter