0 votes
by (120 points)

Lately, I've been getting this exception while using the Search method. Does anyone know why that might be?

Rebex.Net.EwsException: Unexpected XML declaration. The XML declaration must be the first node in the document, and no whitespace characters are allowed to appear before it. Line 1, position 63752.
---> System.Xml.XmlException: Unexpected XML declaration. The XML declaration must be the first node in the document, and no whitespace characters are allowed to appear before it. Line 1, position 63752.
at System.Xml.XmlTextReaderImpl.ParsePI(StringBuilder piInDtdStringBuilder)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at fxvfh.pllks.kxqwt[T](XmlReader p0, xspmd& p1)
at fxvfh.pllks.duppv[T](Stream p0, xspmd& p1)
at fxvfh.atsyx.wwdun[T](String p0, Object p1)
at Rebex.Net.Ews.tzhjw(EwsFolderId p0, EwsItemFields p1, EwsListView p2, EwsSearchParameter p3, String p4)
at Rebex.Net.Ews.voenm.kfezu()
at Rebex.Net.Ews.hubdz[T](String p0, Func1 p1, mfeih p2) --- End of inner exception stack trace --- at Rebex.Net.Ews.hubdz[T](String p0, Func1 p1, mfeih p2)
at Rebex.Net.Ews.Search(EwsFolderId folderId, EwsItemFields fields, EwsListView listView, EwsSearchParameter[] condition)

Applies to: Rebex Secure Mail
by (147k points)
The most likely explanation is wrong response returned by the server that contains a XML content=type, but is not actually XML. Unfortunately, we have encountered EWS servers behaving this way.

Which version of Rebex Mail do you use? We improved error reporting a lot in versions R6.6 and R6.8 (https://www.rebex.net/mail-pack/history.aspx#R6.8), so if you are using an older release, make sure to try a recent one.

If you are already using an up-to-date version, a debug log at LogLevel.Debug or LogLevel.Verbose would make it possible to tell what kind of response was actually received. See https://www.rebex.net/kb/logging/ for information on how to enable logging.

Please log in or register to answer this question.

...