An unhanded exception occurs on a Lync Server 2013 Persistent Chat SDK-based application

Applies to: Lync Server 2013


Assume that you develop an application by using Microsoft Lync Server 2013 Persistent Chat SDK. The application creates multiple endpoints, and users on the endpoints use the application to perform actions in multiple threads. For example, users on the endpoints join a chat room, send a message, and then leave a chat room. In this situation, the application throws the following unhandled exception and then crashes:
Unhandled System.Collections.Generic.KeyNotFoundException
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.Rtc.Collaboration.PersistentChat.Internal.ChatRoomCache.get_Item(Uri uri)
at Microsoft.Rtc.Collaboration.PersistentChat.PersistentChatEndpoint.get_Item(Uri uri)
at Microsoft.Rtc.Collaboration.PersistentChat.Internal.MessageHandler.HandlePartNotify(Object messageIn)
at Microsoft.Rtc.Collaboration.PersistentChat.Internal.MessageHandler.ProcessQueuedMessage(TransportMessage message)
at Microsoft.Rtc.Collaboration.PersistentChat.Internal.MessageRouter.HandleMessage(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()


This issue is caused by a timing issue that occurs between two threads. When one thread deletes an item in a dictionary, and then another thread tries to access the item in the dictionary, the application throws an unhandled KeyNotFoundException exception. Then, the application crashes.


To resolve this issue, install the following cumulative update:
2835432 Description of the cumulative update 5.0.8308.420 for Lync Server 2013, Core Components: July 2013

More Information

For more information about Lync Server 2013 Persistent Chat SDK, go to the following Microsoft website: