# Drawing Style Problem

**URL:** <https://community.thinkgeo.com/t/drawing-style-problem/1592>\
**Category:** WinForms\
**Created:** [February 14, 2011, 8:08am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592 "2011-02-14T08:08:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@Thomas](https://community.thinkgeo.com/u/Thomas)\
**Post date:** [February 14, 2011, 8:08am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/1 "2011-02-14T08:08:17Z")

</div>

Hello&nbsp;ThinkGeo-Team,

we&nbsp;have&nbsp;a&nbsp;problem&nbsp;with&nbsp;some&nbsp;custom&nbsp;styles&nbsp;our&nbsp;users&nbsp;have&nbsp;designed&nbsp;in&nbsp;our&nbsp;GIS-Application&nbsp;where&nbsp;we&nbsp;use&nbsp;ThinkGeo&nbsp;'Desktop-Edition'&nbsp;product.

In&nbsp;some&nbsp;zoomlevels&nbsp;Winforms-Map&nbsp;throws&nbsp;an&nbsp;Exception&nbsp;when&nbsp;drawing&nbsp;a&nbsp;line&nbsp;shape&nbsp;with&nbsp;the&nbsp;custom&nbsp;style:

 ![](https://community.thinkgeo.com/uploads/default/original/1X/c04e085a4e70fedf9269b78c0f4845b6becb358a.png)

I&nbsp;have&nbsp;added&nbsp;a&nbsp;sample&nbsp;application&nbsp;where&nbsp;you&nbsp;can&nbsp;recreate&nbsp;the&nbsp;problem.&nbsp;The&nbsp;error&nbsp;occurs&nbsp;on&nbsp;Windows&nbsp;XP&nbsp;SP3.&nbsp;If&nbsp;we&nbsp;use&nbsp;Windows&nbsp;Vista&nbsp;we&nbsp;do&nbsp;not&nbsp;get&nbsp;any&nbsp;error.

Thomas

[GIS\_InMemoryFLayerIssue.zip](https://community.thinkgeo.com/uploads/default/original/1X/ff2df8765f4cd3a3dafc442b341a431fa5dc91cc.zip) (125 KB)

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [February 14, 2011, 11:16am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/2 "2011-02-14T11:16:35Z")

</div>

Thomas,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;I&nbsp;am&nbsp;part&nbsp;of&nbsp;the&nbsp;ThinkGeo&nbsp;team&nbsp;and&nbsp;after&nbsp;testing&nbsp;your&nbsp;sample&nbsp;app&nbsp;in&nbsp;Windows&nbsp;Vista,&nbsp;I&nbsp;confirm&nbsp;that&nbsp;this&nbsp;is&nbsp;working&nbsp;correctly&nbsp;in&nbsp;that&nbsp;environment.&nbsp;I&nbsp;passed&nbsp;this&nbsp;issue&nbsp;to&nbsp;an&nbsp;other&nbsp;member&nbsp;of&nbsp;ThinkGeo&nbsp;Support&nbsp;to&nbsp;have&nbsp;it&nbsp;tested&nbsp;in&nbsp;XP.&nbsp;We&nbsp;will&nbsp;let&nbsp;you&nbsp;know&nbsp;our&nbsp;findings.&nbsp;Thank&nbsp;you.

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [February 15, 2011, 12:48am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/3 "2011-02-15T00:48:14Z")

</div>

&nbsp;

Thomas,  
&nbsp;  
I&nbsp;have&nbsp;tested&nbsp;your&nbsp;sample&nbsp;at&nbsp;my&nbsp;Windows&nbsp;XP&nbsp;SP3,&nbsp;but&nbsp;can&nbsp;not&nbsp;recreate&nbsp;the&nbsp;Exception&nbsp;just&nbsp;sometimes&nbsp;it&nbsp;displayed&nbsp;a&nbsp;pink&nbsp;background&nbsp;that&nbsp;I&nbsp;think&nbsp;it’s&nbsp;not&nbsp;your&nbsp;problem,&nbsp;the&nbsp;memory&nbsp;usage&nbsp;of&nbsp;entire&nbsp;testing&nbsp;is&nbsp;around&nbsp;100MB&nbsp;so&nbsp;that&nbsp;it&nbsp;couldn’t&nbsp;raise&nbsp;OutOfMemory&nbsp;Exception.  
&nbsp;  
&nbsp;I&nbsp;took&nbsp;a&nbsp;video&nbsp;to&nbsp;show&nbsp;what&nbsp;I&nbsp;test.&nbsp;[hotfile.com/dl/104837027/53f...3.zip.html](http://hotfile.com/dl/104837027/53fde93/post8783.zip.html)  
&nbsp;  
Thanks,  
James

---

<div class="post-metadata">

**Author:** ![Thomas](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@Thomas](https://community.thinkgeo.com/u/Thomas)\
**Post date:** [February 15, 2011, 3:03am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/4 "2011-02-15T03:03:28Z")

</div>

Hello&nbsp;James,

thanks&nbsp;for&nbsp;feedback.

I&nbsp;also&nbsp;think&nbsp;that&nbsp;it&nbsp;is&nbsp;not&nbsp;a&nbsp;memory&nbsp;usage&nbsp;problem.&nbsp;I&nbsp;additional&nbsp;have&nbsp;to&nbsp;say&nbsp;that&nbsp;the&nbsp;sample&nbsp;application&nbsp;did&nbsp;not&nbsp;show&nbsp;exactly&nbsp;the&nbsp;same&nbsp;behaviour&nbsp;as&nbsp;our&nbsp;GIS&nbsp;application.&nbsp;But&nbsp;at&nbsp;the&nbsp;same&nbsp;time&nbsp;the&nbsp;sample&nbsp;application&nbsp;shows&nbsp;the&nbsp;pink&nbsp;background&nbsp;our&nbsp;GIS&nbsp;application&nbsp;throws&nbsp;the&nbsp;exception.

I&nbsp;think&nbsp;the&nbsp;difference&nbsp;between&nbsp;sample&nbsp;and&nbsp;productive&nbsp;GIS&nbsp;application&nbsp;is&nbsp;that&nbsp;we&nbsp;have&nbsp;overide&nbsp;several&nbsp;DrawCore()&nbsp;methods&nbsp;in&nbsp;the&nbsp;GIS&nbsp;application&nbsp;and&nbsp;use&nbsp;our&nbsp;own&nbsp;error&nbsp;handling.

In&nbsp;the&nbsp;sample&nbsp;application&nbsp;the&nbsp;error&nbsp;handling&nbsp;is&nbsp;inside&nbsp;Winforms-Map-Control&nbsp;because&nbsp;I&nbsp;have&nbsp;set&nbsp;the&nbsp;following&nbsp;property:

oOverlay.DrawingExceptionMode&nbsp;=&nbsp;ThinkGeo.MapSuite.Core.

DrawingExceptionMode.DrawException

I&nbsp;have&nbsp;olso&nbsp;found&nbsp;out&nbsp;that&nbsp;the&nbsp;error&nbsp;occurs&nbsp;in&nbsp;relation&nbsp;to&nbsp;the&nbsp;DashCap&nbsp;property&nbsp;of&nbsp;GeoPen&nbsp;that&nbsp;is&nbsp;used&nbsp;to&nbsp;draw&nbsp;the&nbsp;Linestyle.

If&nbsp;I&nbsp;set&nbsp;the&nbsp;Start/End-Cap&nbsp;properties&nbsp;to&nbsp;DrawingLineCap.Flat&nbsp;I&nbsp;don't&nbsp;get&nbsp;any&nbsp;error.&nbsp;I&nbsp;think&nbsp;you&nbsp;have&nbsp;to&nbsp;debug&nbsp;my&nbsp;sample&nbsp;and&nbsp;look&nbsp;inside&nbsp;ThinkGeo-Classes&nbsp;what&nbsp;happen&nbsp;if&nbsp;the&nbsp;pink&nbsp;background&nbsp;is&nbsp;shown.  
  
  
  
Thomas

oLinestyle.InnerPen.EndCap&nbsp;=&nbsp;ThinkGeo.MapSuite.Core.

oLinestyle.InnerPen.StartCap&nbsp;=&nbsp;ThinkGeo.MapSuite.Core.

DrawingLineCap.DiamondAnchorDrawingLineCap.ArrowAnchor

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [February 16, 2011, 3:03am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/5 "2011-02-16T03:03:31Z")

</div>

Thomas,

&nbsp;

This&nbsp;seems&nbsp;a&nbsp;bug&nbsp;from&nbsp;.NET&nbsp;framework.&nbsp;We&nbsp;recreated&nbsp;this&nbsp;problem&nbsp;by&nbsp;the&nbsp;following&nbsp;codes&nbsp;without&nbsp;using&nbsp;MapSuite&nbsp;Assemblies&nbsp;and&nbsp;you&nbsp;can&nbsp;see&nbsp;just&nbsp;these&nbsp;few&nbsp;lines&nbsp;simple&nbsp;code&nbsp;will&nbsp;throw&nbsp;that&nbsp;OutOfMemory&nbsp;Exception.&nbsp;(My&nbsp;machine&nbsp;is&nbsp;Win&nbsp;7&nbsp;X64,&nbsp;8G&nbsp;Memory,&nbsp;Quad&nbsp;Core)&nbsp;

&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;graphics&nbsp;As&nbsp;Graphics&nbsp;=&nbsp;Me.CreateGraphics()

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;pen&nbsp;As&nbsp;Pen&nbsp;=&nbsp;New&nbsp;Pen(Color.Black)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pen.StartCap&nbsp;=&nbsp;Drawing2D.LineCap.ArrowAnchor

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pen.EndCap&nbsp;=&nbsp;Drawing2D.LineCap.DiamondAnchor

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;The&nbsp;following&nbsp;data&nbsp;is&nbsp;generated&nbsp;from&nbsp;your&nbsp;code

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;points&nbsp;As&nbsp;PointF()&nbsp;=&nbsp;New&nbsp;PointF()&nbsp;{New&nbsp;PointF(187.7159,&nbsp;241.4171),&nbsp;New&nbsp;PointF(187.3625,&nbsp;242.0487),&nbsp;New&nbsp;PointF(186.9632,&nbsp;242.7468),&nbsp;New&nbsp;PointF(186.8015,&nbsp;243.0249)}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;graphics.DrawLines(pen,&nbsp;points)

&nbsp;

Please&nbsp;have&nbsp;a&nbsp;try&nbsp;on&nbsp;your&nbsp;machine.&nbsp;&nbsp;And&nbsp;if&nbsp;it's&nbsp;an&nbsp;issue&nbsp;from&nbsp;Microsoft,&nbsp;I'm&nbsp;afraid&nbsp;we&nbsp;cannot&nbsp;do&nbsp;too&nbsp;much&nbsp;about&nbsp;it&nbsp;and&nbsp;we&nbsp;can&nbsp;report&nbsp;it&nbsp;to&nbsp;them.&nbsp;

&nbsp;

Thanks,

James

&nbsp;

[001\_GIS\_InMemoryFLayerIssue.zip](https://community.thinkgeo.com/uploads/default/original/2X/a/a1c4adfc6c6c738298cd315ce1cd128a9979a6c2.zip) (12 KB)  
[002\_001\_screenshot.zip](https://community.thinkgeo.com/uploads/default/original/2X/5/5cf185fcffbbe49319d4d9a0ef9aa7457dc0b0a7.zip) (89.4 KB)

---

<div class="post-metadata">

**Author:** ![Thomas](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@Thomas](https://community.thinkgeo.com/u/Thomas)\
**Post date:** [February 17, 2011, 1:52am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/6 "2011-02-17T01:52:27Z")

</div>

Hello&nbsp;James,&nbsp;  
&nbsp;&nbsp;  
&nbsp;you&nbsp;are&nbsp;right.&nbsp;I&nbsp;get&nbsp;the&nbsp;error&nbsp;only&nbsp;with&nbsp;those&nbsp;few&nbsp;lines&nbsp;of&nbsp;code.&nbsp;Can&nbsp;you&nbsp;please&nbsp;report&nbsp;this&nbsp;bug&nbsp;to&nbsp;Microsoft.&nbsp;Meanwhile&nbsp;I&nbsp;will&nbsp;change&nbsp;my&nbsp;code&nbsp;and&nbsp;disable&nbsp;the&nbsp;according&nbsp;Line-Caps&nbsp;in&nbsp;our&nbsp;application.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;Thomas

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [February 17, 2011, 7:59pm UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/7 "2011-02-17T19:59:37Z")

</div>

Thomas,

We&nbsp;have&nbsp;posted&nbsp;this&nbsp;bug&nbsp;on&nbsp;Microsoft&nbsp;Forum,&nbsp;hope&nbsp;someone&nbsp;will&nbsp;give&nbsp;us&nbsp;a&nbsp;solution&nbsp;for&nbsp;it

[social.msdn.microsoft.com/Fo...27802b954d](http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/5dc19d1b-6da8-4072-abc6-e827802b954d)

James

---

<div class="post-metadata">

**Author:** ![Thomas](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@Thomas](https://community.thinkgeo.com/u/Thomas)\
**Post date:** [February 22, 2011, 7:05am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/8 "2011-02-22T07:05:43Z")

</div>

Hello&nbsp;James,&nbsp;  
&nbsp;&nbsp;  
&nbsp;have&nbsp;you&nbsp;followed&nbsp;the&nbsp;thread&nbsp;in&nbsp;Microsoft&nbsp;Forum.&nbsp;Possible&nbsp;problems&nbsp;are&nbsp;float&nbsp;based&nbsp;points&nbsp;and&nbsp;the&nbsp;resulting&nbsp;lines&nbsp;with&nbsp;length&nbsp;0.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thomas

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [February 23, 2011, 3:13am UTC](https://community.thinkgeo.com/t/drawing-style-problem/1592/9 "2011-02-23T03:13:10Z")

</div>

Hi&nbsp;Thomas,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Even&nbsp;though&nbsp;this&nbsp;answer&nbsp;has&nbsp;been&nbsp;selected&nbsp;as&nbsp;the&nbsp;best&nbsp;answer&nbsp;in&nbsp;the&nbsp;thread,&nbsp;I&nbsp;still&nbsp;doubt&nbsp;it.&nbsp;Apparently,&nbsp;if&nbsp;this&nbsp;exception&nbsp;is&nbsp;cause&nbsp;by&nbsp;the&nbsp;lines&nbsp;with&nbsp;length&nbsp;0,&nbsp;supposing&nbsp;that&nbsp;we&nbsp;remove&nbsp;the&nbsp;last&nbsp;point&nbsp;in&nbsp;the&nbsp;array,&nbsp;the&nbsp;same&nbsp;exception&nbsp;should&nbsp;be&nbsp;thrown.&nbsp;However,&nbsp;we’ve&nbsp;tested&nbsp;this&nbsp;case&nbsp;before&nbsp;and&nbsp;the&nbsp;exception&nbsp;never&nbsp;occurred.&nbsp;Furthermore,&nbsp;if&nbsp;the&nbsp;EndCap&nbsp;is&nbsp;not&nbsp;set,&nbsp;this&nbsp;exception&nbsp;should&nbsp;also&nbsp;be&nbsp;thrown&nbsp;according&nbsp;to&nbsp;this&nbsp;answer,&nbsp;but&nbsp;in&nbsp;fact,&nbsp;we&nbsp;don’t&nbsp;see&nbsp;any&nbsp;exception&nbsp;at&nbsp;all.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Based&nbsp;on&nbsp;these&nbsp;two&nbsp;points,&nbsp;in&nbsp;my&nbsp;opinion,&nbsp;I&nbsp;don’t&nbsp;think&nbsp;they’ve&nbsp;realized&nbsp;where&nbsp;exactly&nbsp;the&nbsp;issue&nbsp;lies,&nbsp;we&nbsp;will&nbsp;follow&nbsp;this&nbsp;thread&nbsp;to&nbsp;see&nbsp;if&nbsp;there’s&nbsp;any&nbsp;update&nbsp;on&nbsp;this&nbsp;issue.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;James&nbsp;
