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