ThinkGeo.com    |     Documentation    |     Premium Support

Crash with WMSLayer

Hi,

We are having following crash when trying to use WMS maps with ThinkGeo 14.1.1.

System.NullReferenceException: Object reference not set to an instance of an object
at ThinkGeo.Core.Async.WmsLayer.<GetRemoteXmlAsync>d__105.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.Async.WmsLayer.<ProcessCapabilitiesAsync>d__102.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.Async.WmsLayer.<OpenAsyncCore>d__87.MoveNext()

This crash happens after configuring WMSOverlayer and calling Map.RefreshAsync(). We are not able to re-produce this in test environment with exactly same wms configuration for debugging but it happens in one setup every time.

It looks look that crash occurs while handling capabilites xml file from server. Could you please check is it possible that crash could occur if something non-valid xml is received from server e.g. due bad network connection ? Or is there any other reason why this could happen ?

Br, Simo

Hi Simo,

Here a couple tricks to help you debug:

  1. Add the following code in your application:

    ThinkGeoDebugger.LogLevel = ThinkGeoLogLevel.All;
    ThinkGeoDebugger.LogType = ThinkGeoLogType.WebRequest;

    // The following line logs the debug info into a StreamWriter to help you locate the issue in runtime.
    ThinkGeoDebugger.LogStreamWriter = yourLogStreamWriter

  2. Hook up the OnReceivedHttpResponseMessage event, which will be raised after receiving a web request, and find out if any issues in receivedHttpRequestEventArgs.ResponseMessage

  3. If the above 2 steps cannot help you locate the issue, please upgrade to the latest beta 14.3.0-beta054 and use WmsAsyncLayer. It will not crash the application and you can find more debug information. We are aiming for having a new release on early February with all the new features/bug fixes in the beta branch.

Thanks,
Ben

Hi,

Problem is that we cannot re-produce this issue in testing environment. It only happens in some production environments and it’s not possible to use debug prints on those.

Since crash occurs on:
System.NullReferenceException: Object reference not set to an instance of an object
at ThinkGeo.Core.Async.WmsLayer.< GetRemoteXmlAsync >d__105.MoveNext()

Can you give any ideas what could be the problem ? Is it more likely caused by some issue with connection or maybe related to xml itself ? It is weird that this seems to be permanent issue on some environments and does not occur at all in others.

Br, Simo

Hi Simon,

With the following code, you can write all the debug info into a log file which also works in production environments.
ThinkGeoDebugger.LogStreamWriter = yourLogStreamWriter

I think on some machines it failed to fetch the Capabilities XML file which crashes the application. You can hook up the SendingHttpRequestMessage and ReceivedHttpResponseMessage events to find out what the request it sends over to the server and what the response it received from the server, which would help with the debug. Both of the events work in production environments.

Thanks,
Ben

Hi,

After some investigation it seems that crash happens when request to get capabilites.xml timeouts. Timeout most probably is caused by slow/limited network connection.

I guess that timeout is not properly handled on WmsLayer ? It would be good to have somekind of handling for timeouts and also it would be good to have also retry mechanism for such case. I think that it is quite a normal case that timeout happens on areas where network coverage is limited/slow.

-Simo

Hi Simo,

Please upgrade to v14.2.2 or the latest beta if you haven’t where we made 2 improvements regarding Capabilities XML in WMS:

  1. Download the compressed capabilities xml if supported by the server.

  2. Make sure to throw the exception in WmsAsyncLayer.OpenCore() if there’s network issues so users can catch it.

Please pull the latest version and try catch the exception from OpenCore(), and do the re-trys in your code. You can also modify the timeouts by changing WmsAsyncLayer.TimeoutInSeconds.

Thanks,
Ben

Hi,

Currently we have WmsOverlay (using DrawingExceptionMode.DrawException) with WmsLayer added to MapView overlays. Crash occurs when MapView.RefreshAsync() is called even we have set DrawException.

Do you know if with 14.2.2 and using WmsAsyncLayer would actually draw exception instead of crash with that kind of setup ?

-Simo

Hi Simo,

We have an Exception Sample in HowDoI where we put an non-existed URI in a wms layer, and this sample shows how we can

a. Draw the exception on the map
b. Customize the exception message, by customizing DrawExceptionCore() method
c, Catch the internal exception through overlay.ThrowingException event

This sample has been added for a while and the current version is using v14.2.2, please have a try here: samples/wpf/HowDoISample · master · ThinkGeo / Public / Desktop Maps · GitLab

Thanks,
Ben