# InvalidOperationException was unhandled

**URL:** <https://community.thinkgeo.com/t/invalidoperationexception-was-unhandled/2254>\
**Category:** WinForms\
**Created:** [May 31, 2013, 12:42am UTC](https://community.thinkgeo.com/t/invalidoperationexception-was-unhandled/2254 "2013-05-31T00:42:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![liu](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://community.thinkgeo.com/u/liu)\
**Post date:** [May 31, 2013, 12:42am UTC](https://community.thinkgeo.com/t/invalidoperationexception-was-unhandled/2254/1 "2013-05-31T00:42:03Z")

</div>

InvalidOperationException&nbsp;was&nbsp;unhandled

Collection&nbsp;was&nbsp;modified;&nbsp;enumeration&nbsp;operation&nbsp;may&nbsp;not&nbsp;execute

Source&nbsp;&nbsp;&nbsp;&nbsp;WpfDesktopEdition

StackTrack&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.WpfDesktopEdition.Tile.\<\>c\_DisplayClass2.\<DrawException\>b\_0()&nbsp;at&nbsp;System.Windows.Threading.Exception&nbsp;Wrapper.InternalRealCall(Delegate&nbsp;callback,&nbsp;Object&nbsp;args,&nbsp;Int32&nbsp;numArgs)

&nbsp;

Do&nbsp;you&nbsp;know&nbsp;what&nbsp;the&nbsp;problem&nbsp;is?

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [June 3, 2013, 10:26am UTC](https://community.thinkgeo.com/t/invalidoperationexception-was-unhandled/2254/2 "2013-06-03T10:26:29Z")

</div>

Hi&nbsp;Liu,&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Would&nbsp;you&nbsp;please&nbsp;provide&nbsp;us&nbsp;a&nbsp;“self-contained”&nbsp;sample&nbsp;for&nbsp;a&nbsp;further&nbsp;test?&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Waiting&nbsp;for&nbsp;your&nbsp;further&nbsp;information&nbsp;  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Johnny&nbsp;

---

<div class="post-metadata">

**Author:** ![liu](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://community.thinkgeo.com/u/liu)\
**Post date:** [June 3, 2013, 9:24pm UTC](https://community.thinkgeo.com/t/invalidoperationexception-was-unhandled/2254/3 "2013-06-03T21:24:19Z")

</div>

1.&nbsp;We&nbsp;add&nbsp;three&nbsp;custom&nbsp;styles&nbsp;to&nbsp;an&nbsp;InMemoryFeatureLayer&nbsp;to&nbsp;draw&nbsp;different&nbsp;features.&nbsp;  
&nbsp;2.&nbsp;We&nbsp;use&nbsp;a&nbsp;timer&nbsp;to&nbsp;refresh&nbsp;the&nbsp;InMemoryFeatureLayer.&nbsp;  
&nbsp;3.&nbsp;In&nbsp;the&nbsp;refresh&nbsp;function,&nbsp;firstly&nbsp;we&nbsp;clear&nbsp;all&nbsp;the&nbsp;features&nbsp;on&nbsp;the&nbsp;InMemoryFeatureLayer,&nbsp;then&nbsp;we&nbsp;add&nbsp;new&nbsp;features&nbsp;on&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;exception&nbsp;will&nbsp;appeared&nbsp;affter&nbsp;running&nbsp;a&nbsp;period&nbsp;of&nbsp;time.

---

<div class="post-metadata">

**Author:** ![liu](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://community.thinkgeo.com/u/liu)\
**Post date:** [June 3, 2013, 9:27pm UTC](https://community.thinkgeo.com/t/invalidoperationexception-was-unhandled/2254/4 "2013-06-03T21:27:01Z")

</div>

1.&nbsp;We&nbsp;add&nbsp;three&nbsp;custom&nbsp;styles&nbsp;to&nbsp;an&nbsp;InMemoryFeatureLayer&nbsp;to&nbsp;draw&nbsp;different&nbsp;features.&nbsp;  
&nbsp;2.&nbsp;We&nbsp;use&nbsp;a&nbsp;timer&nbsp;to&nbsp;refresh&nbsp;the&nbsp;InMemoryFeatureLayer.&nbsp;  
&nbsp;3.&nbsp;In&nbsp;the&nbsp;refresh&nbsp;function,&nbsp;firstly&nbsp;we&nbsp;clear&nbsp;all&nbsp;the&nbsp;features&nbsp;on&nbsp;the&nbsp;InMemoryFeatureLayer,&nbsp;then&nbsp;we&nbsp;add&nbsp;new&nbsp;features&nbsp;on&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;exception&nbsp;will&nbsp;appeared&nbsp;running&nbsp;for&nbsp;a&nbsp;period&nbsp;of&nbsp;time.

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [June 5, 2013, 3:35am UTC](https://community.thinkgeo.com/t/invalidoperationexception-was-unhandled/2254/5 "2013-06-05T03:35:45Z")

</div>

&nbsp;Hi&nbsp;Liu,

&nbsp;

Thanks&nbsp;for&nbsp;your&nbsp;further&nbsp;information,&nbsp;we&nbsp;have&nbsp;tried&nbsp;to&nbsp;recreate&nbsp;the&nbsp;problem&nbsp;but&nbsp;the&nbsp;problem&nbsp;still&nbsp;didn’t&nbsp;show&nbsp;up,&nbsp;attached&nbsp;is&nbsp;our&nbsp;sample&nbsp;code,&nbsp;would&nbsp;you&nbsp;please&nbsp;check&nbsp;it&nbsp;and&nbsp;tell&nbsp;us&nbsp;if&nbsp;we&nbsp;missed&nbsp;anything?

&nbsp;

Waiting&nbsp;for&nbsp;your&nbsp;further&nbsp;information

&nbsp;

Johnny

[Post11278.txt](https://community.thinkgeo.com/uploads/default/original/2X/0/0c14353984e0d8b0f18267bbd8ace66f5b96bdf9.txt) (2.3 KB)
