【发布时间】:2012-04-14 07:43:41
【问题描述】:
我有一个想要持续运行的 EWS 流订阅。它等待特定收件箱中的新邮件事件,当事件触发时,它会读取电子邮件并将内容发布到不同的 Web 服务。在大多数情况下,这很好用,但是每次抛出这个 System.Xml.XmlException:
Unhandled Exception: System.Xml.XmlException: '▼', hexadecimal value 0
invalid character. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& e
32& 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(XmlNodeTyp
)
at Microsoft.Exchange.WebServices.Data.EwsXmlReader.InternalReadEle
mespace xmlNamespace, String localName, XmlNodeType nodeType)
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadRespo
viceXmlReader ewsXmlReader)
at Microsoft.Exchange.WebServices.Data.HangingServiceRequestBase.Pa
es(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(
te)
at System.Threading.ExecutionContext.Run(ExecutionContext execution
ontextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThr
kItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
我看过其他有关此异常的帖子,但似乎都没有解决方案。我怎样才能阻止它被抛出?
更新:
以防万一有人遇到同样的问题。我们将服务器升级到 2010 sp2,问题似乎已解决。
【问题讨论】:
-
我很乐意,但我无法在调试时重新创建异常,所以如果 xml 在电子邮件正文中,如果它是来自 POST 服务器的响应,如果它是重新连接期间来自 Exchange 服务器的响应
-
您需要将日志记录添加到您的异常处理中。又名
try{} catch{ Log.("current email/xml") }之类的东西,如果你曾经复制/修复它。 -
我所有的代码都被
try{} catch(){}异常处理包围了 -
因此,当它捕获时,您需要获取它失败的 xml 并保存它。
-
我明白这一点,从概念上讲,我的代码设置为以这种方式运行(所有其他异常都以这种方式成功管理)。然而,应用程序并没有像我想象的那样工作,而是在控制台上显示了上述异常。
标签: c# xml exception-handling exchangewebservices exchange-server