WPF TabItem Dispose Map implies Nullreferenceexception

Topics: Bugs, WPF
Jan 22, 2012 at 7:17 AM


First Great Job! 

I use GMap.NET in application(wpf) containing tabitem. But GMapControl_Unloaded is called when change tab and when i comeback to tabitem containing the Map i've got Nullreference exception. Actually, Core.OnMapClose() is called.
Is there a Bug?



Jan 22, 2012 at 9:27 AM
Edited Jan 22, 2012 at 9:29 AM

when you came back control is already disposed, check:

  • http://eric.burke.name/dotnetmania/2009/04/26/22.09.28
  • http://stackoverflow.com/questions/2080764/wpf-tabcontrol-how-to-preserve-control-state-within-tab-items-mvvm-pattern
  • http://stackoverflow.com/questions/2238072/tabcontrol-disposes-of-controls-on-inactive-tabs
  • http://www.codeproject.com/Articles/212233/Persist-the-Visual-Tree-when-switching-tabs-in-the
  • http://social.msdn.microsoft.com/Forums/en/wpf/thread/ae5a4101-9d29-49ce-b76b-ad9b09368c9b
Jan 23, 2012 at 10:41 AM


I also test the last beta version and when the GMapControl has been unloaded and next has been re-loaded, I get NullReferenceException in Core::UpdateBounds(): tileDrawingListLock, tileDrawingList and Matrix variables are null.

Indeed, the control is already disposed when it is re-loaded but that does not charge properly.

Do you have any idea ?


Jan 23, 2012 at 11:59 AM

read above

Jan 23, 2012 at 12:29 PM

Test this :


OnSelectionChangedTab( ..... ){

MainMap.SuspendDispose = true;


Jan 28, 2012 at 8:11 AM
Thanks i will try it!

2012/1/23 silviamar <notifications@codeplex.com>

From: silviamar

Test this :

OnSelectionChangedTab( ..... ){

MainMap.SuspendDispose = true;


Read the full discussion online.

To add a post to this discussion, reply to this email (greatmaps@discussions.codeplex.com)

To start a new discussion for this project, email greatmaps@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Jan 30, 2012 at 1:43 PM

I get this crash too, and I do NOT have a tab control.

Sometimes it will crash when another program is loaded. Sometimes it will crash on its own with no other intervention. As with Thitony's comment above, the tileDrawingList and Matrix variables are null.

I've gone through all the links you pointed to, but I can't find any relevance since, as I said, I do not have a tab control, so there are no tabs to switch!

MainMap.SuspendDispose is already true.

Any ideas? 

Jan 30, 2012 at 1:54 PM

SuspendDispose works only once for one dispose, and it never disposes itself randomly, something is causing control to unload so it's unloads

Feb 6, 2012 at 1:33 PM

fixed, now map can be hosted in TabControl without any issues

Feb 6, 2012 at 4:43 PM
Thx Radioman


François LABAT

Le 6 févr. 2012 à 14:34, "radioman" <notifications@codeplex.com> a écrit :

From: radioman

fixed, now map can be hosted in TabControl without any issues

Feb 12, 2014 at 4:24 PM
Mr, radioman
   this bug is still in GMap.net WPF version . this Markers in GMapControl is still there but can't be seen on the map in  changed the tab
Feb 13, 2014 at 10:53 AM
any solutions?