ThinkGeo.com    |     Documentation    |     Premium Support

WmtsAsyncLayer not working

I am investigating the process of upgrading from TG 10 to TG 14. I cannot set up a WMTS layer for some reason. When I try to call the OpenAsync method or the Map tries to draw the layer, I get the following exception:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=ThinkGeo.UI.WinForms
  StackTrace:
   at ThinkGeo.Core.Overlay.<DrawAsync>d__77.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ThinkGeo.Core.MapViewBase.<DrawOverlayAsync>d__368.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at ThinkGeo.Core.MapViewBase.<DrawOverlaysAsync>d__363.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ThinkGeo.Core.MapViewBase.<DrawAsyncCore>d__301.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ThinkGeo.Core.MapViewBase.<DrawAsync>d__300.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ThinkGeo.Core.MapViewBase.<RefreshAsync>d__287.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ThinkGeo.UI.WinForms.MapView.<RefreshAsync>d__88.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ThinkGeo.UI.WinForms.MapView.<RefreshAsync>d__87.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at ThinkGeo_14_Demo.Form1.VB$StateMachine_3_mAddWmtsLayer.MoveNext() in C:\Users\steller\source\repos\ThinkGeo_14_Demo\Form1.vb:line 44

  This exception was originally thrown at this call stack:
    [External Code]
    ThinkGeo_14_Demo.Form1.mAddWmtsLayer() in Form1.vb

I have included a sample project that reproduces the issue.
Any ideas?

Thanks!

SteveThinkGeo_14_Demo.zip (49.6 KB)

Hi Steve,

I can’t run the attached demo because of missing Infragistics components. Can you have a quick look at our Winforms HowDoI samples/winforms/HowDoISample · develop · ThinkGeo / Public / Desktop Maps · GitLab, in which we show 3 WmtsAsyncLayers, as following.

Thanks,
Ben

Sorry about that, I forgot about the Infragistics stuff. The problem only occurs if you don’t include a Uri when you call the constructor. If you do this:

Dim oWmtsLayer As New WmtsAsyncLayer(New Uri(“https://wmts.geo.admin.ch/1.0.0”))

All is well. But if you do this:

Dim oWmtsLayer As New WmtsAsyncLayer()
oWmtsLayer.ServerUri = New Uri(“https://wmts.geo.admin.ch/1.0.0”)

You get a null reference exception when the layer is opened. And that is what our existing application does. I have attached a revised sample project.

Thanks!

Steve

ThinkGeo_14_Demo_No_Infragistics.zip (80.0 KB)

Hi Steve,

The issue is fixed in the latest beta branch (beta-014). Thanks for your demo which is really helpful for fixing the issue!

Thanks,
Ben