2011-07-17 37 views
1

我正在開發一個應用程序,它使用EWS託管API中的StreamingSubscriptionConnection對象。StreamingSubscritionConnection拋出鍵未找到異常

當網絡連接丟失的一段時間它拋出一個異常,其堆棧跟蹤顯示該

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

看來您的客戶端接收到已經終止並從客戶端中刪除的腳本的通知。 StreamingSubscriptionConnection類維護訂閱的內部列表。當它從服務器收到失敗事件時,它會通知客戶端並從該列表中刪除訂閱。如果它收到此訂閱的另一個失敗事件,則會創建您看到的異常。

要解決此問題,請嘗試使用Fiddler(http://www.fiddler2.com/fiddler2/)監視您的客戶端與Exchange服務器之間返回的流量。它充當您的應用程序和Exchange之間的代理,並且可以解密SSL流量。也許這會讓你更深入地瞭解正在發生的事情。