# Exception occured when calling WinformsMap Refresh() method

**URL:** <https://community.thinkgeo.com/t/exception-occured-when-calling-winformsmap-refresh-method/2549>\
**Category:** WinForms\
**Created:** [June 15, 2015, 1:27pm UTC](https://community.thinkgeo.com/t/exception-occured-when-calling-winformsmap-refresh-method/2549 "2015-06-15T13:27:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ariestya](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/b9e5f3/32.png) [@Ariestya](https://community.thinkgeo.com/u/Ariestya)\
**Post date:** [June 15, 2015, 1:27pm UTC](https://community.thinkgeo.com/t/exception-occured-when-calling-winformsmap-refresh-method/2549/1 "2015-06-15T13:27:57Z")

</div>

[![](https://community.thinkgeo.com/uploads/default/original/1X/41893cfe7f74805f8c36ae8386d87d8f3ccc22a0.jpg)](http://thinkgeo.com/forums/DesktopModules/ActiveForums/viewer.aspx?portalid=1&moduleid=623&attachid=6806)Hi.  
  
  
  
Recently&nbsp;I&nbsp;got&nbsp;an&nbsp;unidentified&nbsp;mysterious&nbsp;problem&nbsp;while&nbsp;trying&nbsp;to&nbsp;call&nbsp;Refresh()&nbsp;method&nbsp;in&nbsp;WinformsMap.&nbsp;Inside&nbsp;WinformsMap&nbsp;there’s&nbsp;only&nbsp;1&nbsp;LayerOverlay&nbsp;object&nbsp;consisting&nbsp;of&nbsp;3&nbsp;MsSql2008FeatureLayer&nbsp;(all&nbsp;are&nbsp;not&nbsp;empty),&nbsp;3&nbsp;InMemoryFeatureLayer&nbsp;(only&nbsp;1&nbsp;is&nbsp;used),&nbsp;a&nbsp;scale&nbsp;bar&nbsp;in&nbsp;its&nbsp;AdornmentOverlay,&nbsp;a&nbsp;LegendAdornmentLayer,&nbsp;and&nbsp;an&nbsp;MiniMapAdornmentLayer&nbsp;(taken&nbsp;from&nbsp;official&nbsp;example).  
  
  
  
Due&nbsp;to&nbsp;unseparatable&nbsp;files&nbsp;in&nbsp;the&nbsp;project,&nbsp;I&nbsp;couldn’t&nbsp;attach&nbsp;an&nbsp;example&nbsp;to&nbsp;reproduce&nbsp;the&nbsp;error.&nbsp;But&nbsp;here&nbsp;is&nbsp;the&nbsp;screenshot&nbsp;of&nbsp;the&nbsp;exception&nbsp;StackTrace.&nbsp;I&nbsp;couldn’t&nbsp;pinpoint&nbsp;what&nbsp;caused&nbsp;it&nbsp;as&nbsp;in&nbsp;another&nbsp;method,&nbsp;it&nbsp;works&nbsp;flawlessly.

 ![](https://community.thinkgeo.com/uploads/default/original/1X/0f59cb1098c4ceebf0aa5316a7f969b203a174a7.jpg)  
  
  
  
Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;attention.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [June 16, 2015, 2:37am UTC](https://community.thinkgeo.com/t/exception-occured-when-calling-winformsmap-refresh-method/2549/2 "2015-06-16T02:37:08Z")

</div>

Hi&nbsp;Ariestya,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;have&nbsp;found&nbsp;the&nbsp;function&nbsp;at&nbsp;the&nbsp;top&nbsp;of&nbsp;the&nbsp;exception&nbsp;message,&nbsp;but&nbsp;I&nbsp;am&nbsp;sorry&nbsp;I&nbsp;haven’t&nbsp;found&nbsp;possible&nbsp;issue&nbsp;from&nbsp;here.&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;possible,&nbsp;could&nbsp;you&nbsp;please&nbsp;do&nbsp;some&nbsp;test&nbsp;like&nbsp;this?&nbsp;  
&nbsp;&nbsp;  
&nbsp;1.&nbsp;Create&nbsp;your&nbsp;customMsSql2008FeatureSource&nbsp;inherit&nbsp;from&nbsp;MsSql2008FeatureSource&nbsp;  
&nbsp;2.&nbsp;Override&nbsp;GetFeaturesInsideBoundingBoxCore&nbsp;function,&nbsp;add&nbsp;some&nbsp;monitor&nbsp;code&nbsp;here,&nbsp;or&nbsp;catch&nbsp;exception&nbsp;from&nbsp;base.GetFeaturesInsideBoundingBoxCore()&nbsp;here&nbsp;  
&nbsp;3.&nbsp;Create&nbsp;your&nbsp;customMsSql2008FeatureLayer&nbsp;inherit&nbsp;from&nbsp;MsSql2008FeatureLayer,&nbsp;assign&nbsp;the&nbsp;instance&nbsp;to&nbsp;FeatureSource&nbsp;  
&nbsp;4.&nbsp;Replace&nbsp;MsSql2008FeatureLayer&nbsp;in&nbsp;your&nbsp;code&nbsp;with&nbsp;the&nbsp;new&nbsp;customMsSql2008FeatureLayer&nbsp;  
&nbsp;&nbsp;  
&nbsp;Now&nbsp;you&nbsp;can&nbsp;get&nbsp;more&nbsp;detail&nbsp;exception&nbsp;information,&nbsp;for&nbsp;example&nbsp;the&nbsp;exception&nbsp;parameter&nbsp;or&nbsp;exception&nbsp;message.&nbsp;They&nbsp;will&nbsp;be&nbsp;helpful&nbsp;for&nbsp;us.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Don

---

<div class="post-metadata">

**Author:** ![Ariestya](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/b9e5f3/32.png) [@Ariestya](https://community.thinkgeo.com/u/Ariestya)\
**Post date:** [June 16, 2015, 8:22pm UTC](https://community.thinkgeo.com/t/exception-occured-when-calling-winformsmap-refresh-method/2549/3 "2015-06-16T20:22:33Z")

</div>

Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;response.&nbsp;I’ve&nbsp;done&nbsp;what&nbsp;you&nbsp;suggested&nbsp;but&nbsp;unfortunately,&nbsp;it&nbsp;brought&nbsp;no&nbsp;additional&nbsp;clue&nbsp;of&nbsp;what&nbsp;happened&nbsp;inside&nbsp;GetFeaturesInsideBoundingBoxCore()&nbsp;method.  
  
  
  
And&nbsp;apologize&nbsp;I&nbsp;forget&nbsp;to&nbsp;mention&nbsp;exception’s&nbsp;message&nbsp;was&nbsp;“An&nbsp;item&nbsp;with&nbsp;the&nbsp;same&nbsp;key&nbsp;has&nbsp;already&nbsp;been&nbsp;added.”,&nbsp;so&nbsp;I&nbsp;figure&nbsp;it&nbsp;has&nbsp;to&nbsp;be&nbsp;coming&nbsp;from&nbsp;a&nbsp;private&nbsp;Dictionary&nbsp;(or&nbsp;any&nbsp;Key-Value&nbsp;based&nbsp;IEnumerable)&nbsp;field&nbsp;inside&nbsp;the&nbsp;one&nbsp;of&nbsp;my&nbsp;MsSql2008FeatureLayer&nbsp;object.

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [June 18, 2015, 3:02am UTC](https://community.thinkgeo.com/t/exception-occured-when-calling-winformsmap-refresh-method/2549/4 "2015-06-18T03:02:45Z")

</div>

Hi&nbsp;Ariestya,&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;further&nbsp;information,&nbsp;but&nbsp;this&nbsp;function&nbsp;contains&nbsp;many&nbsp;code,&nbsp;many&nbsp;places&nbsp;used&nbsp;collection&nbsp;so&nbsp;I&nbsp;still&nbsp;cannot&nbsp;locate&nbsp;where&nbsp;is&nbsp;the&nbsp;issue.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Could&nbsp;you&nbsp;please&nbsp;try&nbsp;to&nbsp;simplify&nbsp;your&nbsp;project&nbsp;and&nbsp;get&nbsp;a&nbsp;simplest&nbsp;sample&nbsp;which&nbsp;can&nbsp;reproduce&nbsp;this&nbsp;issue,&nbsp;that&nbsp;should&nbsp;be&nbsp;really&nbsp;helpful.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Don&nbsp;  
&nbsp;&nbsp;
