【发布时间】:2011-10-14 05:12:45
【问题描述】:
我们有一个应用程序使用StreamingSubscriptionConnection 来阅读发送到特定邮箱的每封 封电子邮件。我在开发过程中每天都会遇到几次问题,我得到了异常{"'{square character}', hexadecimal value 0x1F, is an 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.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)
如何使用 EWS 安全阅读包含非法字符的电子邮件?
经过大量搜索,似乎可以使用旧版本的 EWS API 解决此问题。但是,使用最新版本的托管 API 似乎没有人能解决问题。
我已经设法再次获得异常,这里是完整的堆栈跟踪以及 Exchange 正在作为通知的内容。
我使用的是 Exchange 2010 SP1。
编辑:我正在重新提出这个问题,因为它给我带来了严重的问题,而原始问题清楚地说明了问题。我正在寻找修改托管 EWS API 的行为以过滤 XML 中的无效字符并避免异常的客户端解决方案。 Exchange 服务器修复不太可能成为一种选择,除非它们是简单的配置更改。我的软件将在我无法控制的客户 Exchange 服务器上运行。
【问题讨论】:
-
这篇文章在 MSDN 上得到了回答。 social.technet.microsoft.com/Forums/en-US/…
-
Henning:你的意思是social.technet.microsoft.com/Forums/en-US/… 吗?您发布的链接不包含修复,因为我们已经有了 SP1。
-
截至 2014 年,这仍然是托管 API 2.0 的问题。
标签: c# xml exchangewebservices