# WorldMapKitWmsWpfOverlay throws null exception when setting IsVisible

**URL:** <https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763>\
**Category:** WPF\
**Created:** [August 2, 2010, 10:58pm UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763 "2010-08-02T22:58:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Klaus3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/e5b9ba/32.png) [@Klaus3](https://community.thinkgeo.com/u/Klaus3)\
**Post date:** [August 2, 2010, 10:58pm UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/1 "2010-08-02T22:58:01Z")

</div>

&nbsp;Guys,&nbsp;

Just&nbsp;some&nbsp;minor&nbsp;issues&nbsp;I&nbsp;have&nbsp;run&nbsp;into.&nbsp;You&nbsp;may&nbsp;have&nbsp;fixed&nbsp;them&nbsp;or&nbsp;there&nbsp;is&nbsp;a&nbsp;reason&nbsp;behind&nbsp;these&nbsp;behaviors.&nbsp;&nbsp;No&nbsp;worries&nbsp;as&nbsp;I&nbsp;have&nbsp;ways&nbsp;around&nbsp;them.

1.&nbsp;If&nbsp;you&nbsp;try&nbsp;setting&nbsp;the&nbsp;IsVisible&nbsp;property&nbsp;of&nbsp;a&nbsp;WorldMapKitWmsWpfOverlay&nbsp;it&nbsp;throws&nbsp;a&nbsp;null&nbsp;argument&nbsp;exception.&nbsp;&nbsp;&nbsp;

2.&nbsp;Calling&nbsp;WpfMap.ZoomToPreviousExtent&nbsp;fires&nbsp;OnMapExtentChanging&nbsp;event&nbsp;twice.

Thanks,

K

&nbsp;

---

<div class="post-metadata">

**Author:** ![Howard](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/h/90ced4/32.png) [@Howard](https://community.thinkgeo.com/u/Howard)\
**Post date:** [August 3, 2010, 12:23am UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/2 "2010-08-03T00:23:12Z")

</div>

Hi&nbsp;Klaus,&nbsp;  
&nbsp;&nbsp;  
&nbsp;As&nbsp;I&nbsp;tested,&nbsp;when&nbsp;I&nbsp;set&nbsp;WorldMapKitWmsWpfOverlay&nbsp;to&nbsp;invisible,&nbsp;it&nbsp;doesn’t&nbsp;throw&nbsp;exception;&nbsp;I&nbsp;just&nbsp;did&nbsp;a&nbsp;simple&nbsp;test;&nbsp;could&nbsp;you&nbsp;show&nbsp;me&nbsp;the&nbsp;code&nbsp;you&nbsp;are&nbsp;using?&nbsp;For&nbsp;your&nbsp;second&nbsp;issue,&nbsp;I&nbsp;think&nbsp;you&nbsp;might&nbsp;mean&nbsp;CurrentExtentChanging&nbsp;event.&nbsp;I&nbsp;cannot&nbsp;recreate&nbsp;this&nbsp;issue&nbsp;neither&nbsp;with&nbsp;our&nbsp;latest&nbsp;Dll.&nbsp;Please&nbsp;try&nbsp;the&nbsp;latest&nbsp;Dll&nbsp;and&nbsp;try&nbsp;or&nbsp;show&nbsp;us&nbsp;you&nbsp;code&nbsp;so&nbsp;that&nbsp;I&nbsp;can&nbsp;recreate&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;reporting&nbsp;this.&nbsp;  
&nbsp;Howard

---

<div class="post-metadata">

**Author:** ![Klaus3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/e5b9ba/32.png) [@Klaus3](https://community.thinkgeo.com/u/Klaus3)\
**Post date:** [August 3, 2010, 4:21pm UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/3 "2010-08-03T16:21:40Z")

</div>

&nbsp;Howard,&nbsp;

I&nbsp;was&nbsp;just&nbsp;trying&nbsp;something&nbsp;simple&nbsp;like&nbsp;this:

`var worldOverlay = new WorldMapKitWmsWpfOverlay();                worldOverlay.IsVisible = true;                worldOverlay.DrawTilesProgressChanged += OnMapProgressChanged;                map.Overlays.Add("WMK", worldOverlay);`

&nbsp;

If&nbsp;I&nbsp;step&nbsp;through&nbsp;the&nbsp;line&nbsp;where&nbsp;I&nbsp;set&nbsp;IsVisible,&nbsp;an&nbsp;exception&nbsp;is&nbsp;thrown.&nbsp;&nbsp;Maybe&nbsp;I&nbsp;need&nbsp;DII.&nbsp;How&nbsp;do&nbsp;I&nbsp;get&nbsp;this?&nbsp;&nbsp;I&nbsp;am&nbsp;still&nbsp;in&nbsp;eval&nbsp;mode&nbsp;till&nbsp;our&nbsp;purchase&nbsp;comes&nbsp;through.

---

<div class="post-metadata">

**Author:** ![Raquibur](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@Raquibur](https://community.thinkgeo.com/u/Raquibur)\
**Post date:** [August 3, 2010, 4:28pm UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/4 "2010-08-03T16:28:55Z")

</div>

Dear&nbsp;Klaus,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;tested&nbsp;your&nbsp;code.&nbsp;It&nbsp;worked&nbsp;fine&nbsp;for&nbsp;me.&nbsp;I&nbsp;have&nbsp;been&nbsp;working&nbsp;with&nbsp;Map&nbsp;suite&nbsp;for&nbsp;a&nbsp;while.&nbsp;One&nbsp;think&nbsp;i&nbsp;noticed&nbsp;that,&nbsp;the&nbsp;exceptions&nbsp;are&nbsp;misleading.So,&nbsp;my&nbsp;suggestion&nbsp;is&nbsp;that&nbsp;you&nbsp;should&nbsp;check&nbsp;other&nbsp;part&nbsp;of&nbsp;the&nbsp;code&nbsp;and&nbsp;see&nbsp;if&nbsp;your&nbsp;application&nbsp;is&nbsp;generating&nbsp;exception&nbsp;else&nbsp;where.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;  
&nbsp;&nbsp;  
&nbsp;Raquib

---

<div class="post-metadata">

**Author:** ![Raquibur](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@Raquibur](https://community.thinkgeo.com/u/Raquibur)\
**Post date:** [August 3, 2010, 4:29pm UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/5 "2010-08-03T16:29:00Z")

</div>

&nbsp;

---

<div class="post-metadata">

**Author:** ![Klaus3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/e5b9ba/32.png) [@Klaus3](https://community.thinkgeo.com/u/Klaus3)\
**Post date:** [August 3, 2010, 9:14pm UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/6 "2010-08-03T21:14:32Z")

</div>

Raquibur,&nbsp;no,&nbsp;it&nbsp;is&nbsp;definitely&nbsp;not&nbsp;my&nbsp;code.&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;i&nbsp;just&nbsp;modified&nbsp;the&nbsp;DisplayASimpleMap&nbsp;sample&nbsp;as&nbsp;follows:&nbsp;  
&nbsp;`  private void WpfMap_Loaded(object sender, RoutedEventArgs e)        {            Map1.MapUnit = GeographyUnit.DecimalDegree;            Map1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);             WorldMapKitWmsWpfOverlay worldOverlay = new WorldMapKitWmsWpfOverlay();            // Step over this line and a null reference exception is thrown.            // If i set IsVisible to false, however,exception is not thrown.            worldOverlay.IsVisible = true;            Map1.Overlays.Add("WMK", worldOverlay);            Map1.Refresh();        } `&nbsp;  
&nbsp;&nbsp;  
&nbsp;That&nbsp;line&nbsp;throw&nbsp;an&nbsp;exception&nbsp;when&nbsp;IsVisible==&nbsp;true.&nbsp;&nbsp;&nbsp;It&nbsp;could&nbsp;be&nbsp;my&nbsp;DLL&nbsp;versions.&nbsp;I&nbsp;am&nbsp;using&nbsp;4.0.40.

---

<div class="post-metadata">

**Author:** ![Raquibur1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Raquibur1](https://community.thinkgeo.com/u/Raquibur1)\
**Post date:** [August 4, 2010, 12:05am UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/7 "2010-08-04T00:05:56Z")

</div>

Dear&nbsp;Klaus,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;think&nbsp;you&nbsp;are&nbsp;right.&nbsp;I&nbsp;tried&nbsp;with&nbsp;DLL&nbsp;version&nbsp;4.0.40&nbsp;and&nbsp;i&nbsp;get&nbsp;the&nbsp;same&nbsp;issue.&nbsp;  
&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![Howard](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/h/90ced4/32.png) [@Howard](https://community.thinkgeo.com/u/Howard)\
**Post date:** [August 4, 2010, 1:24am UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/8 "2010-08-04T01:24:53Z")

</div>

Hi&nbsp;Klaus,  
  
  
  
I&nbsp;think&nbsp;this&nbsp;is&nbsp;a&nbsp;bug&nbsp;in&nbsp;4.0.40&nbsp;which&nbsp;is&nbsp;fixed&nbsp;in&nbsp;the&nbsp;latest&nbsp;version.&nbsp;Now&nbsp;the&nbsp;latest&nbsp;build&nbsp;is&nbsp;4.0.91.0,&nbsp;you&nbsp;can&nbsp;download&nbsp;the&nbsp;latest&nbsp;package&nbsp;everyday&nbsp;at:  
  
[helpdesk.thinkgeo.com](http://helpdesk.thinkgeo.com)  
  
  
  
Just&nbsp;let&nbsp;me&nbsp;know&nbsp;if&nbsp;you&nbsp;have&nbsp;more&nbsp;queries.  
  
  
  
Thanks,  
  
Howard

---

<div class="post-metadata">

**Author:** ![Klaus3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/e5b9ba/32.png) [@Klaus3](https://community.thinkgeo.com/u/Klaus3)\
**Post date:** [August 4, 2010, 10:03pm UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/9 "2010-08-04T22:03:25Z")

</div>

That&nbsp;was&nbsp;it,&nbsp;thanks&nbsp;Howard.

---

<div class="post-metadata">

**Author:** ![Howard](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/h/90ced4/32.png) [@Howard](https://community.thinkgeo.com/u/Howard)\
**Post date:** [August 6, 2010, 12:11am UTC](https://community.thinkgeo.com/t/worldmapkitwmswpfoverlay-throws-null-exception-when-setting-isvisible/2763/10 "2010-08-06T00:11:32Z")

</div>

Klaus,&nbsp;  
&nbsp;&nbsp;  
&nbsp;You&nbsp;are&nbsp;welcome,&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know&nbsp;if&nbsp;you&nbsp;have&nbsp;more&nbsp;queries.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Howard
