[英]How can I catch this XmlException thrown from third party library?
I'm using the Exchange Web Services managed API and about once a day it throws an XmlException
that I have no idea how to catch. 我正在使用Exchange Web服务托管API,大约每天抛出一个我不知道如何捕获的XmlException
。 Here are the exception details. 以下是例外细节。
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:
From the stacktrace I don't see anything that would allow me to catch and fix the issue. 从堆栈跟踪中我看不到任何可以让我捕获并修复问题的东西。
How can I catch this? 我怎么能抓住这个?
Your XML library doesn't support the 0x1F
char, which is the unit separator char. 您的XML库不支持0x1F
char,它是单位分隔符 char。
What you can do is escape all occurrences of this specific char before your stream/XML file/whatever/ is processed by your XML library. 您可以做的是在您的流/ XML文件/ XML库处理的任何/ 之前转义所有此特定char。 See How do I escape unicode character 0x1F in xml? 请参阅如何在xml中转义unicode字符0x1F?
See allowed character ranges for XML 1.1 . 请参阅XML 1.1的允许字符范围 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.