ThinkGeo.com    |     Documentation    |     Premium Support

Null pointer exception when using a WMS layer

We are using the latest desktop 3.0 edition (WPF) and are connecting to a WMS server. When the WMS server is down, or when there is no internet connection (for example, when using an air card that is not connected) the map throws a null pointer exception on the form Loaded event (which is where we configure the WMS layers) and is disabled thereafter. The null pointer exception is stackless, so I am guessing it happens on a background thread.


Questions


1. Why does the map control throw a stackless NPE exception? This gets caught by our unhandled exception handler. We would prefer to catch the exception so we can modify the state of the map, such as by enabling a "refresh" button.


2. Does the map control tolerate sporadic network drops? if so, what is the best way for us to recover from the network drop without having to close the dialog containing the map and re-opening it?


Thanks!



I forgot to add that in the circumstance described above (WMS server down or network connection down) the map still throws the NPE exception even though we have the map cache turned on. I would think that if the map cache is turned on, the map would check the cache first before hitting the network. Is this correct? 
  
 Thanks!

Gregory,


Thanks for your post.
 
Which version are you trying to use now? I use the latest public release and could not recreate your second problem.
 
1)      The reason for the NPE exception is that we did not handle decently for the exception in the WmsRasterSource & WmsRasterLayer. I have added this item to our working track system and probably we will enhance it in later versions.
 
Currently, to go around this problem, you could write your own WmsRasterSource & WmsRasterLayer, attachment contains the code, hope it helps.
 
2)      If I am not misunderstanding something, what your second problem is that after tiles cached, the network is off or WMS server is shut down, it would throw exception.
 
I think the exception will not be thrown unless new tiles are requested or call the Open again. If all the tiles in the current extent has already been cached, then it will not need to connect to server again as you said.
 
If this problem still exists in your machine with the latest build (3.0.426), could you make a small sample application to show your problems?
 
Thanks.
 
Yale

1253-SampleForWmsRasterSource.zip (11.5 KB)

Thanks, Yale - I’ll give your sample code a try!

Thanks, Yale - I’ll give your sample code a try!

Gregory, 
  
 Thanks for letting us know your status! 
  
 Any more questions please let me know. 
  
 Thanks. 
  
 Yale