An UCMA 3.0 endpoint application throws an unhandled runtime exception in Lync Server 2010

Applies to: Lync Server 2010 Standard EditionLync Server 2010 Enterprise Edition

Symptoms


Assume that you are developing an application by using Microsoft Lync Server 2010, Unified Communications Managed API 3.0 (UCMA3.0). The UCMA application is creating an application endpoint and a user endpoint. When the endpoint runs for several hours in a Lync Server 2010 environment, the application throws an unhandled runtime exception.

Cause


This issue occurs because of a known bug. The bug is triggered when the user endpoint and application endpoint is created in the same platform that has inband query enabled.

Resolution


To resolve this issue, install the following cumulative update:

2500449 Description of the cumulative update for Lync Server 2010, Unified Communications Managed API 3.0 Runtime: November 2011

Workaround


To work around this issue, use one of the following methods:
  • You can set the ProvisioningDataQueryDisabled property to true. This disables the inband query.
  • Because UCMA is highly asynchronous, exceptions are sometimes thrown from a worker thread.

    When an exception is thrown from a worker thread that is used by UCMA, and the exception is not handled within that worker thread, the exception is not caught. This issue also occurs when the application has a “try or catch” function to handle this type of exception. This issue occurs because the exception occurs in the thread context of the UCMA worker thread instead of the thread context of the user code that is called UCMA.

    In order to handle the exception, UCMA has an Exception handler (the UnhandledExceptionManager class) that can be registered in application code for unhandled exceptions in worker threads.

    The following code example shows how to register an UnhandledThreadPoolException Handler delegate with the UnhandledExceptionManager class by setting the VerifyAndIgnoreUnhandledThreadPoolException property:

    // Configure UnhandledExceptionManager class to log uncaught exceptions
    UnhandledExceptionManager.VerifyAndIgnoreUnhandledThreadPoolException = this.LogAndIgnoreUncaughtExceptions;
    The delegate instance is the LogAndIgnoreUncaughtExceptions method of the calling class.The following code example shows how to ignore the exception after you log it:

    bool LogAndIgnoreUncaughtExceptions(Exception ex, WaitCallback method, Object state)
    {
    System.Diagnostics.Trace.WriteLine(ex.ToString());
    return true;
    }
    Note After registering the event, UCMA will pass all unhandled exceptions from worker threads to this event. This will prevent the application from crashing because of this unhandled exception.

More Information


For more information about the ApplicationEndpoint.ProvisioningDataQueryDisabled property, visit the following Microsoft website:
For more information about the UnhandledExceptionManager class, visit the following Microsoft website: