AnsweredAssumed Answered

System.Xml.XmlException: Encountered unexpected character '<'.

Question asked by kunal.mehta@sap.com on Jul 6, 2015

I am using .NET SDK v10.2.4, and recently I've started getting the following exception when trying to load basemap:

 

 

A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll

10:44:59 AM: System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type Esri.ArcGISRuntime.ArcGISServices.MapServiceInfo. Encountered unexpected character '<'. ---> System.Xml.XmlException: Encountered unexpected character '<'.

   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, XmlException exception)

   at System.Runtime.Serialization.Json.XmlJsonReader.ReadAttributes()

   at System.Runtime.Serialization.Json.XmlJsonReader.ReadNonExistentElementName(StringHandleConstStringType elementName)

   at System.Runtime.Serialization.Json.XmlJsonReader.Read()

   at System.Xml.XmlBaseReader.IsStartElement()

   at System.Xml.XmlBaseReader.IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri)

   at System.Runtime.Serialization.XmlReaderDelegator.IsStartElement(XmlDictionaryString localname, XmlDictionaryString ns)

   at System.Runtime.Serialization.XmlObjectSerializer.IsRootElement(XmlReaderDelegator reader, DataContract contract, XmlDictionaryString name, XmlDictionaryString ns)

   at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalIsStartObject(XmlReaderDelegator reader)

   at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)

   at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)

   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)

   --- End of inner exception stack trace ---

   at Esri.ArcGISRuntime.Layers.Layer.<InitializeAsync>b__3(Task`1 t)

   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()

   at System.Threading.Tasks.Task.Execute()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

 

 

The code to initialize basemap is like this:

 

       private async Task InitializeBaseMapAsync(ArcGISTiledMapServiceLayer baseMap)

        {

            if (baseMap != null)

            {

                    try

                    {

                        await baseMap.InitializeAsync();

                        if (baseMap.InitializationException != null)

                        {

                            ...

                        }

                        else

                        {

                            ...

                        }

                        baseMap.IsVisible = true;

                    }

                    catch (Exception ex)

                    {

                        ...

                    }

        }

 

Any help on whats going on or how I can resolve this issue will be greatly appreciated.

 

Thanks.

Outcomes