EWS:无法从传输连接读取数据:连接已关闭

时间:2014-04-21 08:08:11

标签: c# exchange-server exchangewebservices exchange-server-2010

    var message = EmailMessage.Bind(exchangeService, itemid,
                                       new PropertySet(
                                                       ItemSchema.Attachments));




    exchangeService.TraceListener=new TraceListener();
    exchangeService.TraceEnabled = true;
    message.Load(new PropertySet(ItemSchema.MimeContent)); // Getting exception here.
   //  File.WriteAllBytes("email.eml", message.MimeContent.Content);

我在尝试加载mime内容时遇到以下异常。

  

发生了Microsoft.Exchange.WebServices.Data.ServiceRequestException   HResult = -2146233088消息=请求失败。无法读取数据   来自运输连接:连接已关闭   Source = Microsoft.Exchange.WebServices StackTrace:          在Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse)   响应)          在Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()          在Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest 1.Execute() at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalLoadPropertiesForItems(IEnumerable 1   items,PropertySet属性Set,ServiceErrorHandling errorHandling)          在Microsoft.Exchange.WebServices.Data.Item.InternalLoad(PropertySet   属性集)          在Microsoft.Exchange.WebServices.Data.ServiceObject.Load(PropertySet   属性集)          在F:\ Projects \ EmailArchiving \ ConsoleApplication1 \ ConsoleApplication1 \ Program.cs中的ConsoleApplication1.Program.Main(String [] args):行   34 InnerException:System.IO.IOException          的HResult = -2146232800          消息=无法从传输连接读取数据:连接已关闭。          来源=系统          堆栈跟踪:               在System.Net.ConnectStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)               在System.IO.Compression.DeflateStream.Read(Byte []数组,Int32偏移量,Int32计数)               在System.IO.Compression.GZipStream.Read(Byte []数组,Int32偏移量,Int32计数)               在System.Xml.XmlTextReaderImpl.ReadData()               在System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos,Int32& endPos,Int32& outOrChars)               在System.Xml.XmlTextReaderImpl.ParseText()               在System.Xml.XmlTextReaderImpl.ParseElementContent()               在System.Xml.XmlTextReaderImpl.Read()               在System.Xml.XmlTextReader.Read()               在System.Xml.XmlCharCheckingReader.Read()               在Microsoft.Exchange.WebServices.Data.EwsXmlReader.Read()               在Microsoft.Exchange.WebServices.Data.ComplexProperty.InternalLoadFromXml(EwsServiceXmlReader)   reader,XmlNamespace xmlNamespace,String xmlElementName,Func 2 readAction) at Microsoft.Exchange.WebServices.Data.ComplexProperty.LoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName) at Microsoft.Exchange.WebServices.Data.ComplexProperty.LoadFromXml(EwsServiceXmlReader reader, String xmlElementName) at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.InternalLoadFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) at Microsoft.Exchange.WebServices.Data.PropertyBag.LoadFromXml(EwsServiceXmlReader reader, Boolean clear, PropertySet requestedPropertySet, Boolean onlySummaryPropertiesRequested) at Microsoft.Exchange.WebServices.Data.ServiceObject.LoadFromXml(EwsServiceXmlReader reader, Boolean clearPropertyBag, PropertySet requestedPropertySet, Boolean summaryPropertiesOnly) at Microsoft.Exchange.WebServices.Data.EwsServiceXmlReader.ReadServiceObjectsCollectionFromXml[TServiceObject](XmlNamespace collectionXmlNamespace, String collectionXmlElementName, GetObjectInstanceDelegate 1 getObjectInstanceDelegate,Boolean   clearPropertyBag,PropertySet requestedPropertySet,Boolean   summaryPropertiesOnly)               at Microsoft.Exchange.WebServices.Data.EwsServiceXmlReader.ReadServiceObjectsCollectionFromXml [TServiceObject](String   collectionXmlElementName,GetObjectInstanceDelegate 1 getObjectInstanceDelegate, Boolean clearPropertyBag, PropertySet requestedPropertySet, Boolean summaryPropertiesOnly) at Microsoft.Exchange.WebServices.Data.GetItemResponse.ReadElementsFromXml(EwsServiceXmlReader reader) at Microsoft.Exchange.WebServices.Data.ServiceResponse.LoadFromXml(EwsServiceXmlReader reader, String xmlElementName) at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest 1.ParseResponse(EwsServiceXmlReader)   读者)               在Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadResponse(EwsServiceXmlReader)   ewsXmlReader)               在Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponseXml(Stream   responseStream)               在Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse)   响应)          的InnerException:

这种例外的原因是什么?

0 个答案:

没有答案