ThinkGeo.com    |     Documentation    |     Premium Support

KeyNotFoundException was unhandled when calling WinformsMap.Refresh()

I am receiving an intermittent error when zooming in on the map. The specific message is "KeyNotFoundException was unhandled - The given key was not present in the dictionary."


Here is the code I am executing when the error occurs:


 protected void btnZoomIn_Click(object sender, EventArgs e)  {  mapMap.ZoomIn(35);  mapMap.Refresh();  } 


Here is the stack trace after the button click event:


   at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)

   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x03e3d48bcfe7bb6c(IEnumerable`1 xa6f0db4f183189f1)

   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xff5b27c00f9678c2(RectangleShape x178b193eec228e6e)

   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xe3cee4adb9c72451()

   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x9ac8c50f434f4b39(Int32 xb565f4681f05557a)

   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.Refresh()


I have not been able to reliably reproduce the issue. I will continue to see what I can do to determine the situation needed for failure. Machine is Win7 Pro 32bit English. Any ideas what may be the cause of this issue? I could understand this error if I was calling refresh on a specific overlay that did not exist, however I am refreshing the entire map.



 


David,
 
The stack trace is not complete because it’s our fault, I have added this problem in our Issue Tracking system and we will fix this problem later.
 
Before that you can try to do it temporary in your side to get the full stack trace that will be very helpful to find which exact place throw the exception.
First, make sure which overlays you are using, for example, LayerOverlay, GoogleMapsOverlay…etc.
Create customOverlay for each overlay you used, override the DrawCore method like follow code:

 
    public class CustomLayerOverlay : LayerOverlay
    {
        protected override void DrawCore(GeoCanvas canvas)
        {
            try
            {
                base.DrawCore(canvas);
            }
            catch (Exception ex)
            {
                // Put break point here, and show us the stack trace from here
            }
        }
    }

 



Replace the loading code by using custom overlays.
 
And this time, when the exception thrown again, the stack trace will be located the exact methods.
 
If you fell this is not comfortable, please let me know I will think about another way to diagnose this problem.
 
Thanks
 
James