Our product uses the DesktopEdition.WinformsMap control version 4.5.0.148 (the version number on the DLLs we use). After allowing the user to add a raster overlay, and a number of vector overlays, we save their work (what we call a ‘View’) to disk by serializing each of the Overlays in the overlay collection into a stream to file. When the user wants the View, we do the reverse; reading each layer out of the file and adding them to the Overlays collection of a new WinformsMap. We use a tabbed interface and can load the same, or different, views in each tab. This has worked very well for us for over a year.
Recently however, a customer has begun to load fairly large rasters into their views. When I say ‘fairly large’, I don’t mean the file size is all that large (only 4MB or so), I mean that the pixel dimensions are fairly large (4800 x 6700). The product can load one of these large views into about 5 or 6 simultaneous tabs (it varies) before the following error occurs. It can load 10 of them with a raster size of 3700x4500. You can see at the bottom of the stack trace that all I do is call .Refresh() on the Map just as I have called Refresh() on the previous 5 or 6 or 10 other Maps on the other tabs without error.
The machine is not out of memory when this happens; total memory usage is 1.7GB to 2.2GB out of 3GB installed. If views are loaded after the error, they too get the error. If the views do have vector layers in addition to the raster layer, the vector layers do load OK if the error is handled in a try/catch block and execution is allowed to continue.
Any idea why MapSuite.Core thows this error after having successfully completed the code many times on the exact same data?
Parameter is not valid.
at System.Drawing.Image.get_Width()
at ThinkGeo.MapSuite.Core.GdiPlusRasterSource.GetImageWidthCore()
at ThinkGeo.MapSuite.Core.GdiPlusRasterSource.GetBoundingBoxCore()
at ThinkGeo.MapSuite.Core.RasterSource.GetBoundingBox()
at ThinkGeo.MapSuite.Core.RasterLayer.GetBoundingBoxCore()
at ThinkGeo.MapSuite.Core.Layer.GetBoundingBox()
at ThinkGeo.MapSuite.Core.RasterLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.Overlay.MainDraw(GeoCanvas canvas)
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()
at Fusion.fusionMap.RedrawAll() in C:\Users\Dave\Documents\Visual Studio 2010\Projects\Fusion\C3Fusion Client\fusionMap.cs:line 1157
at Fusion.fusionTab.UnpackageViewFromStorage(View _view) in C:\Users\Dave\Documents\Visual Studio 2010\Projects\Fusion\C3Fusion Client\Toolbar.cs:line 720
</Dave>