# Exception in TrackOverlay

**URL:** <https://community.thinkgeo.com/t/exception-in-trackoverlay/3148>\
**Category:** WPF\
**Created:** [February 3, 2012, 3:14pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148 "2012-02-03T15:14:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/3da27b/32.png) [@Ryan1](https://community.thinkgeo.com/u/Ryan1)\
**Post date:** [February 3, 2012, 3:14pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/1 "2012-02-03T15:14:39Z")

</div>

Hi,

While&nbsp;going&nbsp;over&nbsp;our&nbsp;logs&nbsp;of&nbsp;unhandled&nbsp;exceptions&nbsp;experienced&nbsp;by&nbsp;our&nbsp;users,&nbsp;we&nbsp;found&nbsp;the&nbsp;following&nbsp;exception&nbsp;in&nbsp;the&nbsp;TrackOverlay...&nbsp;

&nbsp;

Index&nbsp;must&nbsp;be&nbsp;within&nbsp;the&nbsp;bounds&nbsp;of&nbsp;the&nbsp;List.  
  
Parameter&nbsp;name:&nbsp;index  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument&nbsp;argument,&nbsp;ExceptionResource&nbsp;resource)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Collections.ObjectModel.Collection`1.Insert(Int32&nbsp;index,&nbsp;T&nbsp;item)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.WpfDesktopEdition.TrackInteractiveOverlay.MouseDownCore(InteractionArguments&nbsp;interactionArguments)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.WpfDesktopEdition.InteractiveOverlay.MouseDown(InteractionArguments&nbsp;interactionArguments)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.WpfDesktopEdition.WpfMap.vRU=(InteractionArguments&nbsp;vhU=)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.WpfDesktopEdition.WpfMap.uhU=(Object&nbsp;uxU=,&nbsp;MouseButtonEventArgs&nbsp;vBU=)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;0hM=.VBc=.vRc=(Object&nbsp;vhc=,&nbsp;MouseButtonEventArgs&nbsp;vxc=)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;0hM=.VBc=.wBc=(Object&nbsp;wRc=,&nbsp;MouseButtonEventArgs&nbsp;whc=)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;0hM=.VBc=.OnMouseMove(Object&nbsp;sender,&nbsp;MouseEventArgs&nbsp;e)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate&nbsp;genericHandler,&nbsp;Object&nbsp;genericTarget)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.RoutedEventArgs.InvokeHandler(Delegate&nbsp;handler,&nbsp;Object&nbsp;target)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object&nbsp;target,&nbsp;RoutedEventArgs&nbsp;routedEventArgs)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.EventRoute.InvokeHandlersImpl(Object&nbsp;source,&nbsp;RoutedEventArgs&nbsp;args,&nbsp;Boolean&nbsp;reRaised)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.UIElement.RaiseEventImpl(DependencyObject&nbsp;sender,&nbsp;RoutedEventArgs&nbsp;args)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs&nbsp;args)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.UIElement.RaiseEvent(RoutedEventArgs&nbsp;args,&nbsp;Boolean&nbsp;trusted)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Input.InputManager.ProcessStagingArea()  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Input.InputManager.ProcessInput(InputEventArgs&nbsp;input)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Input.InputProviderSite.ReportInput(InputReport&nbsp;inputReport)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr&nbsp;&nbsp;hwnd,&nbsp;InputMode&nbsp;mode,&nbsp;Int32&nbsp;timestamp,&nbsp;RawMouseActions&nbsp;actions,&nbsp;Int32&nbsp;x,&nbsp;&nbsp;Int32&nbsp;y,&nbsp;Int32&nbsp;wheel)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr&nbsp;&nbsp;hwnd,&nbsp;WindowMessage&nbsp;msg,&nbsp;IntPtr&nbsp;wParam,&nbsp;IntPtr&nbsp;lParam,&nbsp;Boolean&&nbsp;&nbsp;handled)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr&nbsp;hwnd,&nbsp;&nbsp;Int32&nbsp;msg,&nbsp;IntPtr&nbsp;wParam,&nbsp;IntPtr&nbsp;lParam,&nbsp;Boolean&&nbsp;handled)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;MS.Win32.HwndWrapper.WndProc(IntPtr&nbsp;hwnd,&nbsp;Int32&nbsp;msg,&nbsp;IntPtr&nbsp;wParam,&nbsp;IntPtr&nbsp;lParam,&nbsp;Boolean&&nbsp;handled)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object&nbsp;o)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate&nbsp;callback,&nbsp;Object&nbsp;args,&nbsp;Int32&nbsp;numArgs)  
  
&nbsp;&nbsp;&nbsp;at&nbsp;MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object&nbsp;&nbsp;source,&nbsp;Delegate&nbsp;method,&nbsp;Object&nbsp;args,&nbsp;Int32&nbsp;numArgs,&nbsp;Delegate&nbsp;&nbsp;catchHandler)

&nbsp;

I&nbsp;only&nbsp;have&nbsp;the&nbsp;stacktrace&nbsp;and&nbsp;don't&nbsp;know&nbsp;what&nbsp;the&nbsp;user&nbsp;was&nbsp;doing&nbsp;to&nbsp;produce&nbsp;this&nbsp;error.&nbsp;&nbsp;I&nbsp;would&nbsp;guess&nbsp;it&nbsp;has&nbsp;something&nbsp;to&nbsp;do&nbsp;with&nbsp;drawing&nbsp;just&nbsp;based&nbsp;off&nbsp;the&nbsp;stack&nbsp;trace...&nbsp;any&nbsp;insight&nbsp;would&nbsp;be&nbsp;appreciated.

&nbsp;

.Ryan.

---

<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:** [February 7, 2012, 8:42am UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/2 "2012-02-07T08:42:25Z")

</div>

Hello&nbsp;Ryan,&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post,&nbsp;this&nbsp;is&nbsp;not&nbsp;our&nbsp;internal&nbsp;exception,&nbsp;so&nbsp;sorry&nbsp;to&nbsp;say&nbsp;without&nbsp;sample&nbsp;or&nbsp;how&nbsp;to&nbsp;recreate&nbsp;it,&nbsp;we&nbsp;don’t&nbsp;know&nbsp;the&nbsp;root&nbsp;cause,&nbsp;and&nbsp;I&nbsp;have&nbsp;checked&nbsp;the&nbsp;code,&nbsp;possibly&nbsp;it’s&nbsp;caused&nbsp;by&nbsp;polygon&nbsp;track,&nbsp;it&nbsp;should&nbsp;have&nbsp;three&nbsp;vertex&nbsp;to&nbsp;create&nbsp;a&nbsp;polygon,&nbsp;and&nbsp;maybe&nbsp;the&nbsp;trackoverlay&nbsp;only&nbsp;contains&nbsp;one&nbsp;or&nbsp;two&nbsp;vertex&nbsp;or&nbsp;none.&nbsp;So&nbsp;the&nbsp;code&nbsp;below&nbsp;throw&nbsp;exception.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;this.Vertices[2]&nbsp;=&nbsp;new&nbsp;Vertex(xInWorld,&nbsp;yInWorld);&nbsp;  
&nbsp;&nbsp;  
&nbsp;But&nbsp;I&nbsp;don’t&nbsp;why&nbsp;it&nbsp;will&nbsp;happen,&nbsp;so&nbsp;if&nbsp;you&nbsp;can&nbsp;find&nbsp;a&nbsp;way&nbsp;to&nbsp;recreate&nbsp;it&nbsp;or&nbsp;provide&nbsp;a&nbsp;sample,&nbsp;that&nbsp;will&nbsp;be&nbsp;helpful.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Ryan1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/3da27b/32.png) [@Ryan1](https://community.thinkgeo.com/u/Ryan1)\
**Post date:** [February 7, 2012, 3:27pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/3 "2012-02-07T15:27:05Z")

</div>

okay,&nbsp;so&nbsp;I&nbsp;was&nbsp;able&nbsp;to&nbsp;track&nbsp;down&nbsp;how&nbsp;to&nbsp;reproduce&nbsp;it...&nbsp;the&nbsp;bug&nbsp;has&nbsp;to&nbsp;do&nbsp;with&nbsp;some&nbsp;code&nbsp;I&nbsp;got&nbsp;from&nbsp;a&nbsp;previous&nbsp;post&nbsp;on&nbsp;programatically&nbsp;cancelling&nbsp;a&nbsp;track&nbsp;layer.&nbsp;&nbsp;I've&nbsp;attached&nbsp;a&nbsp;sample.&nbsp;&nbsp;If&nbsp;you&nbsp;click&nbsp;polygon,&nbsp;draw&nbsp;a&nbsp;couple&nbsp;points&nbsp;but&nbsp;don't&nbsp;complete&nbsp;it,&nbsp;click&nbsp;the&nbsp;cancel&nbsp;button,&nbsp;then&nbsp;click&nbsp;polygon&nbsp;and&nbsp;try&nbsp;to&nbsp;draw&nbsp;a&nbsp;point,&nbsp;the&nbsp;application&nbsp;explodes&nbsp;with&nbsp;the&nbsp;exception.&nbsp;&nbsp;Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;help.

&nbsp;

.Ryan.

[003\_002\_001\_WpfApplication1.zip](https://community.thinkgeo.com/uploads/default/original/2X/4/49b87a85834bcf9824556b8391e95e86661b2093.zip) (14.3 KB)

---

<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:** [February 8, 2012, 12:19pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/4 "2012-02-08T12:19:24Z")

</div>

Hello&nbsp;Ryan,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;further&nbsp;information,&nbsp;that&nbsp;helps&nbsp;a&nbsp;lot,&nbsp;I&nbsp;can&nbsp;recreate&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;will&nbsp;find&nbsp;the&nbsp;root&nbsp;cause&nbsp;and&nbsp;post&nbsp;here&nbsp;as&nbsp;soon&nbsp;as&nbsp;possible.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Ryan1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/3da27b/32.png) [@Ryan1](https://community.thinkgeo.com/u/Ryan1)\
**Post date:** [March 9, 2012, 4:27pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/5 "2012-03-09T16:27:13Z")

</div>

Hi&nbsp;Gary,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Just&nbsp;wanted&nbsp;to&nbsp;see&nbsp;if&nbsp;you&nbsp;have&nbsp;any&nbsp;follow&nbsp;up&nbsp;to&nbsp;this&nbsp;issue&nbsp;yet?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;.Ryan.

---

<div class="post-metadata">

**Author:** ![Ryan1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/3da27b/32.png) [@Ryan1](https://community.thinkgeo.com/u/Ryan1)\
**Post date:** [March 15, 2012, 5:23pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/6 "2012-03-15T17:23:37Z")

</div>

Bump

---

<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:** [March 21, 2012, 4:11pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/7 "2012-03-21T16:11:41Z")

</div>

Hello&nbsp;Ryan,

My&nbsp;apologize,&nbsp;we&nbsp;have&nbsp;resolved&nbsp;this&nbsp;problem&nbsp;long&nbsp;time&nbsp;ago,&nbsp;but&nbsp;looks&nbsp;like&nbsp;it's&nbsp;a&nbsp;internal&nbsp;system&nbsp;error,&nbsp;we&nbsp;lost&nbsp;the&nbsp;connection&nbsp;with&nbsp;this&nbsp;post,&nbsp;I&nbsp;finally&nbsp;find&nbsp;the&nbsp;resolve&nbsp;solution&nbsp;in&nbsp;our&nbsp;system&nbsp;and&nbsp;post,&nbsp;sorry&nbsp;for&nbsp;long&nbsp;time&nbsp;waiting.

The&nbsp;error&nbsp;reason&nbsp;is&nbsp;in&nbsp;you&nbsp;cancel&nbsp;method,&nbsp;you&nbsp;didn't&nbsp;clear&nbsp;all&nbsp;necessary&nbsp;property,&nbsp;except&nbsp;clean&nbsp;the&nbsp;vertices&nbsp;and&nbsp;change&nbsp;the&nbsp;trackmode,&nbsp;you&nbsp;still&nbsp;need&nbsp;to&nbsp;set&nbsp;MouseDownCount&nbsp;and&nbsp;clear&nbsp;the&nbsp;tracking&nbsp;flag.

Please&nbsp;check&nbsp;the&nbsp;code&nbsp;below:

`        public void Cancel()        {            if (TrackShapeLayer.InternalFeatures.Count > 0)            {                TrackShapeLayer.InternalFeatures.RemoveAt(TrackShapeLayer.InternalFeatures.Count - 1);            }            EndTracking();            MouseDownCount = 0;            Vertices.Clear();            TrackMode = TrackMode.None;            Refresh();        }`

Thanks&nbsp;for&nbsp;your&nbsp;patience,&nbsp;regards,

Gary

---

<div class="post-metadata">

**Author:** ![Ryan1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/3da27b/32.png) [@Ryan1](https://community.thinkgeo.com/u/Ryan1)\
**Post date:** [March 22, 2012, 12:40pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/8 "2012-03-22T12:40:53Z")

</div>

Thanks&nbsp;Gary…&nbsp;no&nbsp;problem&nbsp;about&nbsp;the&nbsp;delay,&nbsp;the&nbsp;code&nbsp;worked&nbsp;perfectly…&nbsp;thank&nbsp;you&nbsp;very&nbsp;much&nbsp;:)!

---

<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:** [March 22, 2012, 4:47pm UTC](https://community.thinkgeo.com/t/exception-in-trackoverlay/3148/9 "2012-03-22T16:47:17Z")

</div>

Hello&nbsp;Ryan,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know&nbsp;your&nbsp;problems.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary
