I have added a sample application where you can recreate the problem. The error occurs on Windows XP SP3. If we use Windows Vista we do not get any error.
I am part of the ThinkGeo team and after testing your sample app in Windows Vista, I confirm that this is working correctly in that environment. I passed this issue to an other member of ThinkGeo Support to have it tested in XP. We will let you know our findings. Thank you.
I have tested your sample at my Windows XP SP3, but can not recreate the Exception just sometimes it displayed a pink background that I think it’s not your problem, the memory usage of entire testing is around 100MB so that it couldn’t raise OutOfMemory Exception.
I also think that it is not a memory usage problem. I additional have to say that the sample application did not show exactly the same behaviour as our GIS application. But at the same time the sample application shows the pink background our GIS application throws the exception.
I think the difference between sample and productive GIS application is that we have overide several DrawCore() methods in the GIS application and use our own error handling.
In the sample application the error handling is inside Winforms-Map-Control because I have set the following property:
I have olso found out that the error occurs in relation to the DashCap property of GeoPen that is used to draw the Linestyle.
If I set the Start/End-Cap properties to DrawingLineCap.Flat I don't get any error. I think you have to debug my sample and look inside ThinkGeo-Classes what happen if the pink background is shown.
This seems a bug from .NET framework. We recreated this problem by the following codes without using MapSuite Assemblies and you can see just these few lines simple code will throw that OutOfMemory Exception. (My machine is Win 7 X64, 8G Memory, Quad Core)
Dim graphics As Graphics = Me.CreateGraphics()
Dim pen As Pen = New Pen(Color.Black)
pen.StartCap = Drawing2D.LineCap.ArrowAnchor
pen.EndCap = Drawing2D.LineCap.DiamondAnchor
' The following data is generated from your code
Dim points As PointF() = New PointF() {New PointF(187.7159, 241.4171), New PointF(187.3625, 242.0487), New PointF(186.9632, 242.7468), New PointF(186.8015, 243.0249)}
graphics.DrawLines(pen, points)
Please have a try on your machine. And if it's an issue from Microsoft, I'm afraid we cannot do too much about it and we can report it to them.
you are right. I get the error only with those few lines of code. Can you please report this bug to Microsoft. Meanwhile I will change my code and disable the according Line-Caps in our application.
Even though this answer has been selected as the best answer in the thread, I still doubt it. Apparently, if this exception is cause by the lines with length 0, supposing that we remove the last point in the array, the same exception should be thrown. However, we’ve tested this case before and the exception never occurred. Furthermore, if the EndCap is not set, this exception should also be thrown according to this answer, but in fact, we don’t see any exception at all.
Based on these two points, in my opinion, I don’t think they’ve realized where exactly the issue lies, we will follow this thread to see if there’s any update on this issue.