# KeyNotFoundException

**URL:** <https://community.thinkgeo.com/t/keynotfoundexception/3362>\
**Category:** WPF\
**Created:** [January 4, 2013, 11:06am UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362 "2013-01-04T11:06:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Miguel1](https://community.thinkgeo.com/u/Miguel1)\
**Post date:** [January 4, 2013, 11:06am UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/1 "2013-01-04T11:06:44Z")

</div>

Hello,

We&nbsp;have&nbsp;an&nbsp;application&nbsp;running&nbsp;for&nbsp;2&nbsp;years&nbsp;and&nbsp;suddenly&nbsp;it&nbsp;started&nbsp;to&nbsp;crash&nbsp;with&nbsp;a&nbsp;KeyNotFoundException,&nbsp;even&nbsp;when&nbsp;we&nbsp;are&nbsp;not&nbsp;doing&nbsp;nothing.&nbsp;But&nbsp;there&nbsp;are&nbsp;some&nbsp;data&nbsp;from&nbsp;geo&nbsp;positioning&nbsp;vehicles.

&nbsp;

The&nbsp;stack&nbsp;trace:

Application:&nbsp;XVIAE.exe&nbsp;Framework&nbsp;Version:&nbsp;v4.0.30319&nbsp;Description:&nbsp;The&nbsp;process&nbsp;was&nbsp;terminated&nbsp;due&nbsp;to&nbsp;an&nbsp;unhandled&nbsp;exception.&nbsp;Exception&nbsp;Info:&nbsp;System.Collections.Generic.KeyNotFoundException&nbsp;Stack:&nbsp;at&nbsp;ThinkGeo.MapSuite.WpfDesktopEdition.Tile.DrawException(ThinkGeo.MapSuite.Core.GeoCanvas,&nbsp;System.Exception)&nbsp;at&nbsp;ThinkGeo.MapSuite.WpfDesktopEdition.Tile.Draw(ThinkGeo.MapSuite.Core.GeoCanvas)&nbsp;at&nbsp;ThinkGeo.MapSuite.WpfDesktopEdition.Tile.sxM=(System.Object)&nbsp;at&nbsp;System.Threading.QueueUserWorkItemCallback.WaitCallback\_Context(System.Object)&nbsp;at&nbsp;System.Threading.ExecutionContext.runTryCode(System.Object)&nbsp;at&nbsp;System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode,&nbsp;CleanupCode,&nbsp;System.Object)&nbsp;at&nbsp;System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,&nbsp;System.Threading.ContextCallback,&nbsp;System.Object)&nbsp;at&nbsp;System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,&nbsp;System.Threading.ContextCallback,&nbsp;System.Object,&nbsp;Boolean)&nbsp;at&nbsp;System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()&nbsp;at&nbsp;System.Threading.ThreadPoolWorkQueue.Dispatch()&nbsp;at&nbsp;System.Threading.\_ThreadPoolWaitCallback.PerformWaitCallback()&nbsp;

&nbsp;

The&nbsp;version&nbsp;is&nbsp;5.0.81.

Does&nbsp;anyone&nbsp;have&nbsp;a&nbsp;clue&nbsp;what&nbsp;might&nbsp;be&nbsp;the&nbsp;problem?

&nbsp;

Best&nbsp;regards

AF

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [January 4, 2013, 8:16pm UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/2 "2013-01-04T20:16:19Z")

</div>

Hello&nbsp;Miguel,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post,&nbsp;so&nbsp;looks&nbsp;like&nbsp;you&nbsp;didn’t&nbsp;change&nbsp;or&nbsp;upgrade&nbsp;the&nbsp;MapSuite&nbsp;dll&nbsp;version,&nbsp;but&nbsp;suddenly&nbsp;throw&nbsp;this&nbsp;error.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Can&nbsp;you&nbsp;provide&nbsp;more&nbsp;information?&nbsp;What’s&nbsp;the&nbsp;operate&nbsp;before&nbsp;the&nbsp;exception&nbsp;throw?&nbsp;Is&nbsp;that&nbsp;possible&nbsp;you&nbsp;can&nbsp;provide&nbsp;a&nbsp;sample&nbsp;that&nbsp;can&nbsp;recreate&nbsp;the&nbsp;problem?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Miguel1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Miguel1](https://community.thinkgeo.com/u/Miguel1)\
**Post date:** [January 7, 2013, 9:17am UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/3 "2013-01-07T09:17:42Z")

</div>

Hello,&nbsp;  
&nbsp;&nbsp;  
&nbsp;My&nbsp;dll&nbsp;version&nbsp;is&nbsp;5.0.81.0&nbsp;  
&nbsp;We&nbsp;have&nbsp;15&nbsp;layers&nbsp;with&nbsp;asynchronous&nbsp;updates&nbsp;that&nbsp;can&nbsp;be&nbsp;performed&nbsp;on&nbsp;map&nbsp;changes&nbsp;in&nbsp;the&nbsp;various&nbsp;layers&nbsp;together.&nbsp;  
&nbsp;The&nbsp;operation&nbsp;consists&nbsp;in&nbsp;redesigning&nbsp;a&nbsp;set&nbsp;of&nbsp;objects&nbsp;on&nbsp;the&nbsp;map,&nbsp;every&nbsp;minute,&nbsp;and&nbsp;each&nbsp;layer&nbsp;has&nbsp;10&nbsp;objects&nbsp;on&nbsp;average.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Tiago&nbsp;Neves

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [January 8, 2013, 3:55am UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/4 "2013-01-08T03:55:00Z")

</div>

Hello&nbsp;Miguel,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Most&nbsp;time&nbsp;this&nbsp;exception&nbsp;is&nbsp;happened&nbsp;when&nbsp;you&nbsp;try&nbsp;to&nbsp;add/edit/delete&nbsp;features,&nbsp;sometimes&nbsp;user&nbsp;are&nbsp;using&nbsp;internalFeature&nbsp;to&nbsp;directly&nbsp;operate&nbsp;the&nbsp;feature&nbsp;but&nbsp;and&nbsp;forget&nbsp;to&nbsp;call&nbsp;the&nbsp;r-tree&nbsp;to&nbsp;rebuilt,&nbsp;this&nbsp;will&nbsp;make&nbsp;the&nbsp;feature&nbsp;disappeared&nbsp;but&nbsp;the&nbsp;the&nbsp;index&nbsp;still&nbsp;exist&nbsp;in&nbsp;the&nbsp;r-tree,&nbsp;is&nbsp;that&nbsp;possible&nbsp;this&nbsp;is&nbsp;the&nbsp;problem&nbsp;in&nbsp;your&nbsp;scenario?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;I&nbsp;have&nbsp;to&nbsp;ask&nbsp;a&nbsp;small&nbsp;self-contained&nbsp;sample&nbsp;to&nbsp;recreate&nbsp;your&nbsp;problem.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Miguel1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Miguel1](https://community.thinkgeo.com/u/Miguel1)\
**Post date:** [January 8, 2013, 5:19am UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/5 "2013-01-08T05:19:30Z")

</div>

Hello&nbsp;Gary,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Whenever&nbsp;we&nbsp;perform&nbsp;these&nbsp;operations&nbsp;run&nbsp;the&nbsp;r-tree.&nbsp;  
&nbsp;However&nbsp;our&nbsp;code&nbsp;has&nbsp;thousands&nbsp;of&nbsp;lines&nbsp;of&nbsp;code,&nbsp;thus&nbsp;sending&nbsp;complex&nbsp;examples.&nbsp;  
&nbsp;We&nbsp;also&nbsp;intend&nbsp;to&nbsp;upgrade&nbsp;to&nbsp;version&nbsp;6,&nbsp;and&nbsp;would&nbsp;like&nbsp;to&nbsp;know&nbsp;if&nbsp;you&nbsp;could&nbsp;protect&nbsp;your&nbsp;code&nbsp;on&nbsp;your&nbsp;side&nbsp;(in&nbsp;your&nbsp;dll),&nbsp;so&nbsp;that&nbsp;the&nbsp;application&nbsp;does&nbsp;not&nbsp;blind?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Tiago&nbsp;Neves

---

<div class="post-metadata">

**Author:** ![Miguel1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Miguel1](https://community.thinkgeo.com/u/Miguel1)\
**Post date:** [January 10, 2013, 11:53am UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/6 "2013-01-10T11:53:33Z")

</div>

Hello,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;wonder&nbsp;if&nbsp;they&nbsp;already&nbsp;have&nbsp;an&nbsp;answer&nbsp;regarding&nbsp;this&nbsp;item,&nbsp;if&nbsp;you&nbsp;are&nbsp;invertigar&nbsp;and&nbsp;we&nbsp;arrived&nbsp;at&nbsp;any&nbsp;conclusion.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;&nbsp;  
&nbsp;Tiago&nbsp;Neves

---

<div class="post-metadata">

**Author:** ![Matthew4](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@Matthew4](https://community.thinkgeo.com/u/Matthew4)\
**Post date:** [January 10, 2013, 1:54pm UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/7 "2013-01-10T13:54:50Z")

</div>

This&nbsp;happens&nbsp;to&nbsp;me&nbsp;a&nbsp;lot.&nbsp;The&nbsp;tech&nbsp;support&nbsp;said&nbsp;it&nbsp;was&nbsp;a&nbsp;threading&nbsp;issue&nbsp;where&nbsp;the&nbsp;map&nbsp;is&nbsp;being&nbsp;drawn&nbsp;while&nbsp;we&nbsp;are&nbsp;manipulating&nbsp;feature(s).&nbsp;Our&nbsp;solution&nbsp;was&nbsp;two&nbsp;fold:

1)&nbsp;Every&nbsp;LayerOverlay&nbsp;that&nbsp;we&nbsp;create&nbsp;has&nbsp;its&nbsp;LockLayerMode&nbsp;property&nbsp;set&nbsp;to&nbsp;Lock  
  
2)&nbsp;Before&nbsp;adding/deleting/changing&nbsp;one&nbsp;or&nbsp;more&nbsp;features&nbsp;(we&nbsp;chunk&nbsp;as&nbsp;much&nbsp;as&nbsp;possible&nbsp;btw)&nbsp;we&nbsp;lock&nbsp;the&nbsp;layer  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Since&nbsp;we&nbsp;use&nbsp;C#&nbsp;we&nbsp;do&nbsp;a&nbsp;lock(myInMemoryFeaturelayer)&nbsp;{&nbsp;/\*&nbsp;update&nbsp;the&nbsp;feature(s)&nbsp;\*/&nbsp;}  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;fixed&nbsp;about&nbsp;98%&nbsp;of&nbsp;the&nbsp;occurances&nbsp;of&nbsp;this&nbsp;exception.&nbsp;They&nbsp;still&nbsp;happen&nbsp;but&nbsp;much&nbsp;more&nbsp;rare&nbsp;now.

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [January 11, 2013, 12:59am UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/8 "2013-01-11T00:59:17Z")

</div>

Hello&nbsp;Miguel,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;for&nbsp;delay,&nbsp;it&nbsp;seems&nbsp;like&nbsp;encountered&nbsp;a&nbsp;missing&nbsp;for&nbsp;a&nbsp;resource,&nbsp;&nbsp;but&nbsp;I’m&nbsp;not&nbsp;sure&nbsp;what’s&nbsp;root&nbsp;cause&nbsp;without&nbsp;recreate&nbsp;it.&nbsp;So,&nbsp;below&nbsp;is&nbsp;some&nbsp;suggestion&nbsp;we&nbsp;can&nbsp;try:&nbsp;  
&nbsp;&nbsp;  
&nbsp;a.&nbsp;The&nbsp;program&nbsp;has&nbsp;been&nbsp;Run&nbsp;2&nbsp;years,&nbsp;it&nbsp;might&nbsp;encounter&nbsp;a&nbsp;new&nbsp;data&nbsp;from&nbsp;the&nbsp;new&nbsp;data&nbsp;source.&nbsp;Please&nbsp;check&nbsp;your&nbsp;recently&nbsp;data.&nbsp;  
&nbsp;b.&nbsp;Please&nbsp;set&nbsp;“DrawingExceptionMode”&nbsp;to&nbsp;“ThrowException”&nbsp;for&nbsp;every&nbsp;layer&nbsp;which&nbsp;was&nbsp;in&nbsp;specified&nbsp;overlay.&nbsp;Then,&nbsp;you&nbsp;can&nbsp;get&nbsp;a&nbsp;concrete&nbsp;exception,&nbsp;and&nbsp;paste&nbsp;here&nbsp;to&nbsp;see&nbsp;if&nbsp;we&nbsp;can&nbsp;get&nbsp;further&nbsp;information.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;for&nbsp;the&nbsp;inconvenience.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary&nbsp;

---

<div class="post-metadata">

**Author:** ![Miguel1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Miguel1](https://community.thinkgeo.com/u/Miguel1)\
**Post date:** [January 11, 2013, 3:50am UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/9 "2013-01-11T03:50:17Z")

</div>

Hello&nbsp;Gary,&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;two&nbsp;points&nbsp;that&nbsp;have&nbsp;already&nbsp;been&nbsp;tested&nbsp;referiste&nbsp;and&nbsp;the&nbsp;problem&nbsp;continues&nbsp;to&nbsp;occur.&nbsp;  
&nbsp;We&nbsp;are&nbsp;thinking&nbsp;about&nbsp;moving&nbsp;to&nbsp;version&nbsp;6.&nbsp;I&nbsp;wonder&nbsp;if&nbsp;this&nbsp;version&nbsp;of&nbsp;the&nbsp;problem&nbsp;no&nbsp;longer&nbsp;occurs?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Tiago&nbsp;Neves

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [January 13, 2013, 11:02pm UTC](https://community.thinkgeo.com/t/keynotfoundexception/3362/10 "2013-01-13T23:02:36Z")

</div>

Hi&nbsp;Miguel,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;think&nbsp;you&nbsp;could&nbsp;have&nbsp;a&nbsp;try,&nbsp;the&nbsp;new&nbsp;version&nbsp;has&nbsp;many&nbsp;new&nbsp;features&nbsp;and&nbsp;fixed&nbsp;some&nbsp;bugs,&nbsp;maybe&nbsp;this&nbsp;bug&nbsp;is&nbsp;in&nbsp;one&nbsp;of&nbsp;them,&nbsp;please&nbsp;let&nbsp;us&nbsp;know&nbsp;your&nbsp;result.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Edgar
