# System.NullReferenceException

**URL:** <https://community.thinkgeo.com/t/system-nullreferenceexception/3657>\
**Category:** WPF\
**Created:** [May 14, 2014, 1:53pm UTC](https://community.thinkgeo.com/t/system-nullreferenceexception/3657 "2014-05-14T13:53:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/f08c70/32.png) [@Brandon](https://community.thinkgeo.com/u/Brandon)\
**Post date:** [May 14, 2014, 1:53pm UTC](https://community.thinkgeo.com/t/system-nullreferenceexception/3657/1 "2014-05-14T13:53:24Z")

</div>

Hello&nbsp;again.&nbsp;&nbsp;I&nbsp;was&nbsp;going&nbsp;through&nbsp;my&nbsp;project,&nbsp;and&nbsp;stumbled&nbsp;upon&nbsp;an&nbsp;exception&nbsp;and&nbsp;am&nbsp;looking&nbsp;for&nbsp;clarification.&nbsp;&nbsp;  
  
  
  
Here&nbsp;are&nbsp;the&nbsp;basics:&nbsp;&nbsp;I&nbsp;am&nbsp;using&nbsp;over&nbsp;a&nbsp;dozen&nbsp;layers&nbsp;as&nbsp;basemaps,&nbsp;which&nbsp;are&nbsp;set&nbsp;to&nbsp;draw&nbsp;from&nbsp;a&nbsp;tile&nbsp;cache.&nbsp;&nbsp;I&nbsp;then&nbsp;have&nbsp;about&nbsp;19&nbsp;other&nbsp;layers&nbsp;that&nbsp;aren’t&nbsp;cached.&nbsp;&nbsp;I&nbsp;am&nbsp;using&nbsp;GoogleMaps&nbsp;for&nbsp;a&nbsp;base&nbsp;layer,&nbsp;which&nbsp;is&nbsp;also&nbsp;pulling&nbsp;from&nbsp;cached&nbsp;tiles.  
  
  
  
How&nbsp;it&nbsp;crashed:&nbsp;&nbsp;I&nbsp;decided&nbsp;to&nbsp;‘play&nbsp;user’&nbsp;and&nbsp;pan&nbsp;and&nbsp;zoom&nbsp;the&nbsp;map&nbsp;around&nbsp;quickly&nbsp;as&nbsp;if&nbsp;I&nbsp;were&nbsp;looking&nbsp;for&nbsp;something&nbsp;specific.&nbsp;&nbsp;After&nbsp;a&nbsp;little&nbsp;bit,&nbsp;it&nbsp;gave&nbsp;me&nbsp;the&nbsp;System.NullReferenceException&nbsp;and&nbsp;the&nbsp;following&nbsp;stack&nbsp;trace.&nbsp;&nbsp;I&nbsp;have&nbsp;also&nbsp;done&nbsp;the&nbsp;same&nbsp;thing&nbsp;and&nbsp;gotten&nbsp;an&nbsp;ObjectDisposedException.&nbsp;&nbsp;  
  
  
  
My&nbsp;assumption:&nbsp;&nbsp;I&nbsp;am&nbsp;assuming&nbsp;that&nbsp;somewhere&nbsp;in&nbsp;the&nbsp;ThinkGeo&nbsp;back&nbsp;end,&nbsp;there&nbsp;is&nbsp;a&nbsp;process&nbsp;trying&nbsp;to&nbsp;call&nbsp;a&nbsp;reference&nbsp;to&nbsp;a&nbsp;tile&nbsp;that&nbsp;has&nbsp;been&nbsp;changed&nbsp;or&nbsp;no&nbsp;longer&nbsp;exists.&nbsp;&nbsp;However,&nbsp;I&nbsp;cannot&nbsp;fully&nbsp;see&nbsp;more&nbsp;information&nbsp;about&nbsp;it.  
  
  
  
What&nbsp;I&nbsp;need&nbsp;to&nbsp;know:&nbsp;&nbsp;I&nbsp;am&nbsp;looking&nbsp;for&nbsp;a&nbsp;way&nbsp;to&nbsp;somehow&nbsp;track&nbsp;down&nbsp;the&nbsp;root&nbsp;cause&nbsp;of&nbsp;these&nbsp;types&nbsp;of&nbsp;exceptions&nbsp;or&nbsp;at&nbsp;the&nbsp;very&nbsp;least,&nbsp;have&nbsp;a&nbsp;way&nbsp;to&nbsp;handle&nbsp;them.&nbsp;&nbsp;Unfortunately,&nbsp;they&nbsp;do&nbsp;not&nbsp;happen&nbsp;in&nbsp;my&nbsp;main&nbsp;program&nbsp;so&nbsp;I&nbsp;cannot&nbsp;try&nbsp;to&nbsp;catch&nbsp;them&nbsp;and&nbsp;handle&nbsp;them.&nbsp;&nbsp;Is&nbsp;there&nbsp;some&nbsp;manner&nbsp;in&nbsp;which&nbsp;I&nbsp;would&nbsp;be&nbsp;able&nbsp;to&nbsp;get&nbsp;more&nbsp;access&nbsp;to&nbsp;your&nbsp;internal&nbsp;error&nbsp;handling&nbsp;to&nbsp;avoid&nbsp;shut&nbsp;downs&nbsp;like&nbsp;this?&nbsp;&nbsp;Basically,&nbsp;I&nbsp;am&nbsp;looking&nbsp;for&nbsp;a&nbsp;solution&nbsp;besides&nbsp;telling&nbsp;a&nbsp;user&nbsp;not&nbsp;to&nbsp;do&nbsp;something.&nbsp;&nbsp;Telling&nbsp;them&nbsp;not&nbsp;to&nbsp;pan&nbsp;quickly&nbsp;or&nbsp;zoom&nbsp;quickly&nbsp;because&nbsp;it&nbsp;will&nbsp;crash&nbsp;isn’t&nbsp;our&nbsp;best&nbsp;option.

> `at ThinkGeo.MapSuite.WpfDesktopEdition.Tile.<>c __DisplayClass6.<``DrawException``>b__ 4()`  
> `at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)`  
> `at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)`  
> `at System.Windows.Threading.DispatcherOperation.InvokeImpl()`  
> `at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)`  
> `at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)`  
> `at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)`  
> `at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)`  
> `at System.Windows.Threading.DispatcherOperation.Invoke()`  
> `at System.Windows.Threading.Dispatcher.ProcessQueue()`  
> `at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)`  
> `at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)`  
> `at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)`  
> `at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)`  
> `at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)`  
> `at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)`  
> `at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)`  
> `at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)`  
> `at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)`  
> `at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)`  
> `at System.Windows.Threading.Dispatcher.Run()`  
> `at System.Windows.Application.RunDispatcher(Object ignore)`  
> `at System.Windows.Application.RunInternal(Window window)`  
> `at System.Windows.Application.Run(Window window)`  
> `at System.Windows.Application.Run()`  
> `at WPS_Test.Application.Main() in C:\Users\colemanb\Desktop\Rover Files\ThinkGeo_Test\PHI_Test_Projection\WPS_Test\WPS_Test\obj\x86\Debug\Application.g.vb:line 65`

---

<div class="post-metadata">

**Author:** ![Troy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@Troy](https://community.thinkgeo.com/u/Troy)\
**Post date:** [May 15, 2014, 12:08am UTC](https://community.thinkgeo.com/t/system-nullreferenceexception/3657/2 "2014-05-15T00:08:56Z")

</div>

Hi&nbsp;Brandon,  
  
  
  
Can&nbsp;you&nbsp;make&nbsp;sure&nbsp;which&nbsp;layer&nbsp;results&nbsp;to&nbsp;the&nbsp;crash&nbsp;and&nbsp;don’t&nbsp;forget&nbsp;to&nbsp;turn&nbsp;on&nbsp;the&nbsp;exception&nbsp;catch&nbsp;in&nbsp;VS?&nbsp;we&nbsp;can&nbsp;comment&nbsp;out&nbsp;the&nbsp;layers&nbsp;one&nbsp;by&nbsp;one&nbsp;to&nbsp;narrow&nbsp;down&nbsp;the&nbsp;crash&nbsp;reason.  
  
  
  
In&nbsp;case&nbsp;this&nbsp;is&nbsp;an&nbsp;internal&nbsp;exception&nbsp;in&nbsp;map&nbsp;suite&nbsp;component,&nbsp;we&nbsp;can&nbsp;set&nbsp;the&nbsp;DrawingExceptionMode&nbsp;as&nbsp;ThrowException&nbsp;on&nbsp;each&nbsp;LayerOverlay&nbsp;to&nbsp;get&nbsp;more&nbsp;details&nbsp;of&nbsp;the&nbsp;exception&nbsp;and&nbsp;the&nbsp;DrawingException&nbsp;event&nbsp;also&nbsp;might&nbsp;be&nbsp;useful.  
  
  
  
Hope&nbsp;it&nbsp;will&nbsp;help&nbsp;you&nbsp;to&nbsp;get&nbsp;more&nbsp;details&nbsp;of&nbsp;the&nbsp;crash.  
  
Thanks,  
  
Troy
