ThinkGeo.com    |     Documentation    |     Premium Support

Attempted to read or write protected memory. This is often an indication that other memory is corrupt

I'm displaying three lines to show distance to a point and the East/West and North/South distances.  If I'm zoomed down so that one of the distances is zero, I one of the exceptions below.  There is no recovery from this one as it throws you out of the app.  I am working around by not displaying the E/W N/S lines if the distance is less than 1 meter.


System.ExecutionEngineException was unhandled

Message: An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.


or


System.AccessViolationException occurred

  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

  Source="System.Drawing"

  StackTrace:

       at System.Drawing.SafeNativeMethods.Gdip.GdipDrawLines(HandleRef graphics, HandleRef pen, HandleRef points, Int32 count)

       at System.Drawing.Graphics.DrawLines(Pen pen, PointF[] points)

       at ThinkGeo.MapSuite.Core.GdiPlusGeoCanvas.DrawLineCore(IEnumerable`1 screenPoints, GeoPen linePen, DrawingLevel drawingLevel, Single xOffset, Single yOffset)

       at ThinkGeo.MapSuite.Core.GeoCanvas.x031f76d2da9fbe52(Byte[] x99e09ceb3e6636a9, Int32 xedf77fd65cf83220, Single xce919ea4a4b048be, Single x4e6c8c21e101dfe6, DrawingLevel x1aab732a2c56566f, GeoPen x0860aa02a02a22f7)

       at ThinkGeo.MapSuite.Core.GeoCanvas.DrawLine(Feature feature, GeoPen linePen, DrawingLevel drawingLevel, Single xOffset, Single yOffset)

       at ThinkGeo.MapSuite.Core.LineStyle.DrawCore(IEnumerable`1 features, GeoCanvas canvas, Collection`1 labelsInThisLayer, Collection`1 labelsInAllLayers)

       at ThinkGeo.MapSuite.Core.Style.Draw(IEnumerable`1 features, GeoCanvas canvas, Collection`1 labelsInThisLayer, Collection`1 labelsInAllLayers)

       at ThinkGeo.MapSuite.Core.ZoomLevel.DrawCore(GeoCanvas canvas, IEnumerable`1 features, Collection`1 currentLayerLabels, Collection`1 allLayerLabels)

       at ThinkGeo.MapSuite.Core.ZoomLevel.Draw(GeoCanvas canvas, IEnumerable`1 features, Collection`1 currentLayerLabels, Collection`1 allLayerLabels)

       at ThinkGeo.MapSuite.Core.FeatureLayer.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.Draw(GeoCanvas canvas)

       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x27d0591c2adda8d9(RectangleShape xb35a33b423b17f65, Overlay x99251f66cdabc2ad, Int32 xa209325f5c895f7e, Int32 x7454a0d1965919b1, GeographyUnit xbb704b4400ce6f76)

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

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

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

       at GISMapping.MapSuiteControl.RefreshMap() in C:\CMS\GISMapping\MapSuiteControl.cs:line 3422

 


 



David, 
  
   Can you create a small sample app that demonstrates this?  It can just be a map on a form, with zoom-in button or something.  This will help us quickly troubleshoot the problem. 
  
 On another note, we did not intent for the map control to be used at scales around one meter.  The main reason is that in GIS we usually deal with geographic features and you don’t see too many of those at one meter scales.  I understand that many points can be that small but rarely do you need to zoom into those levels.  I was surprised that it even let you.  I had thought that we restricted the amount you could zoom in.  The problems are that many geographic features are very large and when you zoom in that small GDI+ has a hard time dealing with the size of the numbers it generates.  Our only option is to cut out the small windows from the feature and that is really really slow.  Would you be find with a floor for it or do you need to see at one meter?  I am not sure we can handle that requirement now.  Maybe I am totally missing the point though. 
  
 David

It will be awhile before I can get you a sample app.  We're trying to get our product out the door (I know you can relate).  I have a workaround so it is not urgent for me.  Just wanted to let you know that it was out there.


I was not zooming down to the meter level.  My minimum scale is 200.  I am painting these lines on the mouse move so when I'm zoomed down I can get to a point where the mouse is directly above or to the side of my measuring point.  I'm sure it would happen at other zoom levels too but usually the mouse won't line up.



David, 
  
  I understand about getting things out the door! :-)  Just shoot me the code when you get a chance, I would really like to see it so we can get it fixed or at least identify the problem. 
  
 David

The attached project shows the exception.  Just move your mouse around until you get a 0 reading in one of the directions.  I couldn't send the whole project because of the 250K restriction but this should do.



1214-Form1.cs (7.18 KB)

David,



If I am not misunderstood, the exception will happen when your mouse and point in Vertical position or Horizontal position shown below, While it seems strange that this will not happen in my test machine. The attachment is the code (no change from your Form1.cs).


 



 
Any more questions please feel free to let me know.
 
Thanks.
 
Yale

1217-Post_6276Sample.zip (11.3 KB)

The length of the line seems to be of a bigger scale than I get.  Here is the .designer.cs and .resx files I should have sent previously.  I put the .cs extension on the resx file to get it to upload.  Should have scrapped these into one zip file but scrapped that plan when I hit the size limit. It is very reproducable for me.  It may be that the minium scale is not down to 200 on yours.



1218-Form1.Designer.cs (3.3 KB)
1219-Form1.resx.cs (5.87 KB)

David, 
  
 This problem will not happens in Win7 OS, while it is obvious very easy to recreate as your said in WinXP or Vista. 
  
 Following after more investigation, I will give you a way of workaround. 
  
 Thanks. 
  
 Yale 


David, 
  
 This problem is caused by a bug in GetShortestLineTo API when passing in the DecimalDegree as parameter, and we have fixed this problem. 
  
 Currently, there is a way to go around the problem is by passing the Meter instead of DecimalDegree as its parameter, I think you need to change 3 places in the MouseMove event codes(For DFeature, XFeature, YFeature separately). 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale