StreamingSubscritionConnection抛出Key not found异常

时间:2011-07-17 17:43:37

标签: exchangewebservices ews-managed-api

我正在开发一个在EWS托管API中使用StreamingSubscriptionConnection对象的应用程序。

当网络连接丢失一段时间后,它会抛出一个异常,其StackTrace显示此

System.Collections.Generic.KeyNotFoundException was unhandled
  Message=The given key was not present in the dictionary.
  Source=mscorlib
  StackTrace:
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Microsoft.Exchange.WebServices.Data.StreamingSubscriptionConnection.IssueSubscriptionFailures(GetStreamingEventsResponse gseResponse)
       at Microsoft.Exchange.WebServices.Data.StreamingSubscriptionConnection.HandleServiceResponseObject(Object response)
       at Microsoft.Exchange.WebServices.Data.HangingServiceRequestBase.ParseResponses(Object state)
       at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
  InnerException: 

任何人都知道为什么会发生这种情况?

提前致谢。

1 个答案:

答案 0 :(得分:1)

您的客户似乎收到已经终止并从客户端删除的下标的通知。 StreamingSubscriptionConnection类维护一个内部订阅列表。当它从服务器接收到故障事件时,它通知客户端并从所述列表中删除订阅。如果它收到此订阅的另一个失败事件,则会创建您看到的异常。

要解决此问题,请尝试使用Fiddler监控客户端与Exchange服务器之间返回的流量(http://www.fiddler2.com/fiddler2/)。它充当您的应用程序和Exchange之间的代理,它可以解密SSL流量。也许这会让你更深入地了解正在发生的事情。