0

我正在使用 Exchange Web Services 托管 API,大约每天一次它会抛出一个XmlException我不知道如何捕捉的问题。以下是异常详细信息。

System.Xml.XmlException was unhandled
  Message="'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1."
  Source="System.Xml"
  LineNumber=1
  LinePosition=1
  SourceUri=""
  StackTrace:
       at System.Xml.XmlTextReaderImpl.Throw(Exception e)
       at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
       at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args)
       at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Int32 pos, Char invChar)
       at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
       at System.Xml.XmlTextReaderImpl.ParseText()
       at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
       at System.Xml.XmlTextReaderImpl.Read()
       at Microsoft.Exchange.WebServices.Data.EwsXmlReader.Read()
       at Microsoft.Exchange.WebServices.Data.EwsXmlReader.Read(XmlNodeType nodeType)
       at Microsoft.Exchange.WebServices.Data.EwsXmlReader.InternalReadElement(XmlNamespace xmlNamespace, String localName, XmlNodeType nodeType)
       at Microsoft.Exchange.WebServices.Data.EwsXmlReader.ReadStartElement(XmlNamespace xmlNamespace, String localName)
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadResponse(EwsServiceXmlReader ewsXmlReader)
       at Microsoft.Exchange.WebServices.Data.HangingServiceRequestBase.ParseResponses(Object state)
       at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
  InnerException: 

从堆栈跟踪中,我看不到任何可以让我发现并解决问题的东西。

我怎么能抓住这个?

4

1 回答 1

2

您的 XML 库不支持0x1Fchar,它是单位分隔符char。

您可以做的是在您的流/XML 文件/whatever/ 由您的 XML 库处理之前转义所有出现的此特定字符。请参阅如何在 xml 中转义 unicode 字符 0x1F?

请参阅XML 1.1 允许的字符范围

于 2012-07-13T13:42:03.967 回答