locked
Lync Client is in an invalid state RRS feed

  • Question

  • I'm trying to write an UI suppressed application. Somehow after initializing the client, it becomes to an invalid state (LyncClient.State = ClientState.Invalid) I tried to login/logout from the official client, tried to restart the computer, but none of them works. How could I get out of the invalid state? Is it possible programatically?
    Tuesday, May 3, 2011 7:30 PM

Answers

  • I think I've got it working. It seems that if I don't instantiate the LyncClient in a visual component (ex: Window) it will fail. I've put the _LyncClient = LyncClient.GetClient(); and initialization code into a window's loaded event handler and the problem went away. I don't understand why is that :(
    Tuesday, May 10, 2011 8:44 AM

All replies

  • It's hard to say why it is getting into the invalid state without seeing the code. Can you post up your initialisation code?
    Wednesday, May 4, 2011 8:48 AM
  • It comes from the SDK, and it worked before. Here is the code:

     

     void Create()
    _LyncClient = LyncClient.GetClient(); _LyncClient.StateChanged += new EventHandler<ClientStateChangedEventArgs>(_LyncClient_StateChanged); _LyncClient.ClientDisconnected += new EventHandler(_LyncClient_ClientDisconnected); if (_LyncClient.InSuppressedMode) { _LyncClient_Initialize(); } }
    void _LyncClient_Initialize() { if (_LyncClient.State == ClientState.Uninitialized) { try { _LyncClient.BeginInitialize(EndInitializeCallBack, _LyncClient); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } } }


    Wednesday, May 4, 2011 8:52 AM
  • Are you also programatically signing in to Lync? I've seen a similar issue where CredentialRequested is not handled properly, which can put the client into an invalid state.

    When you call SignIn, if Lync needs to present login credentials, the CredentialRequested event will fire. Make sure that you are either presenting the required credentials, or calling cancel - e.g.

     

    private static void Client_CredentialRequested(object sender, CredentialRequestedEventArgs e)
    {
      try
      {
        if (e.Type == CredentialRequestedType.SignIn)
        {
          // Submit username/password
          e.Submit("<username>", "<password>", true);
        }
        else
        {
          // Cancel any other credential requests
          e.Cancel(true);
        }
      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.ToString());
      }
    }

     

    Generally in this case, after you exit the app an instance of Communicator.exe will still be running - kill it in task manager before you run your app again.

    Wednesday, May 4, 2011 9:56 AM
  • I think I've got it working. It seems that if I don't instantiate the LyncClient in a visual component (ex: Window) it will fail. I've put the _LyncClient = LyncClient.GetClient(); and initialization code into a window's loaded event handler and the problem went away. I don't understand why is that :(
    Tuesday, May 10, 2011 8:44 AM