Hello,there.Sorry about my poor english.
I am adding a wmtslayer by using the following code.
But there is a exception occurs while WmtsService loading.
The Exception says:Invalid XML.: Parser couldn't move inside Keywords.
Here's the call stack:
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
在 ArcGISRuntime.WPF.Samples.WMTSLayer.WMTSLayer.<Button2_Click>d__2.MoveNext() 位置 C:\Workbench\sources\arcgis-runtime-samples-dotnet-master\src\WPF\ArcGISRuntime.WPF.Viewer\Samples\Layers\WMTSLayer\WMTSLayer.xaml.cs:行号 72
Any idea why this exception happens?
You can find the capacities xml from attachment.
<SPAN class="keyword token">try</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Define the Uri to the WMTS service</SPAN>
<SPAN class="keyword token">var</SPAN> myUri <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Uri</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fxxxxx%3A8080%2Fgeoserver%2Fgwc%2Fservice%2Fwmts" target="_blank">http://xyz:8080/geoserver/gwc/service/wmts</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Define a new instance of the WMTS service</SPAN>
WmtsService myWmtsService <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">WmtsService</SPAN><SPAN class="punctuation token">(</SPAN>myUri<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Load the WMTS service </SPAN>
<SPAN class="keyword token">await</SPAN> myWmtsService<SPAN class="punctuation token">.</SPAN><SPAN class="token function">LoadAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Get the service information (i.e. metadata) about the WMTS service</SPAN>
WmtsServiceInfo myWMTSServiceInfo <SPAN class="operator token">=</SPAN> myWmtsService<SPAN class="punctuation token">.</SPAN>ServiceInfo<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Obtain the read only list of WMTS layer info objects</SPAN>
IReadOnlyList<SPAN class="operator token"><</SPAN>WmtsLayerInfo<SPAN class="operator token">></SPAN> myWmtsLayerInfos <SPAN class="operator token">=</SPAN> myWMTSServiceInfo<SPAN class="punctuation token">.</SPAN>LayerInfos<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Create a new instance of a WMTS layer using the first item in the read only list of WMTS layer info objects</SPAN>
WmtsLayer myWmtsLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">WmtsLayer</SPAN><SPAN class="punctuation token">(</SPAN>myWmtsLayerInfos<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Create a new map</SPAN>
Map myMap <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Map</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Get the basemap from the map</SPAN>
Basemap myBasemap <SPAN class="operator token">=</SPAN> myMap<SPAN class="punctuation token">.</SPAN>Basemap<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Get the layer collection for the base layers</SPAN>
LayerCollection myLayerCollection <SPAN class="operator token">=</SPAN> myBasemap<SPAN class="punctuation token">.</SPAN>BaseLayers<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Add the WMTS layer to the layer collection of the map</SPAN>
myLayerCollection<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Add</SPAN><SPAN class="punctuation token">(</SPAN>myWmtsLayer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Assign the map to the MapView</SPAN>
MyMapView<SPAN class="punctuation token">.</SPAN>Map <SPAN class="operator token">=</SPAN> myMap<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">catch</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token class-name">Exception</SPAN> ex<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
MessageBox<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Show</SPAN><SPAN class="punctuation token">(</SPAN>ex<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Thank you!