UI抑制 - 客户端停留在SigningIn状态

问题描述 投票:0回答:1

我尝试通过我的应用程序登录到Skype的业务。

当我与UI的时候,我可以登录。

当我设置UI抑制,我的客户是停留在状态的签署。无论凭据事件,也不SigninCallback事件,也不SignInDelayed事件。

你能帮助我吗?

这里是我的代码:

public void StartUpSkype()
    {

        try
        {

            _LyncClient = LyncClient.GetClient();
            if (_LyncClient == null)
            {
                throw new Exception("Unable to obtain client interface");
            }
            if (_LyncClient.InSuppressedMode == true)
            {
                if (_LyncClient.State == ClientState.Uninitialized)
                {
                    Object[] _asyncState = { _LyncClient };
                    _LyncClient.BeginInitialize(InitializeCallback, _asyncState);
                }
            }
            _LyncClient.SignInDelayed += _LyncClient_SignInDelayed;
            _LyncClient.StateChanged += _Client_ClientStateChanged;
            _LyncClient.CredentialRequested += _LyncClient_CredentialRequested;

        }
        catch (NotStartedByUserException h)
        {
            DisplayErrorMessage("Lync is not running");
        }
        catch (Exception ex)
        {
            DisplayErrorMessage("General Exception");
        }
    }

void _Client_ClientStateChanged(Object source, ClientStateChangedEventArgs data)
    {
        if (data != null)
        {
            if (data.NewState == ClientState.SignedIn)
            {
                DisplayErrorMessage("Signed in");
                UserIsSignedIn?.Invoke(_LyncClient);
            }
            if (data.NewState == ClientState.SignedOut)
            {
                string login = ConfigurationManager.AppSettings["loginSkypeClient"];
                string password = ConfigurationManager.AppSettings["pwdSkypeClient"];

                _LyncClient.SignInConfiguration.ForgetMe(login);

                try
                {
                    // starts the sign in process asynchronously
                    IAsyncResult asyncResult = _LyncClient.BeginSignIn(login, login, password, SigninCallback, _LyncClient);

                    // But wait for the results because the events cannot be registered within a worker thread.
                    asyncResult.AsyncWaitHandle.WaitOne();

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
    }

    void _LyncClient_CredentialRequested(object sender, CredentialRequestedEventArgs e)
    {
        string login = ConfigurationManager.AppSettings["loginSkypeClient"];
        string password = ConfigurationManager.AppSettings["pwdSkypeClient"];

        if (e.Type == CredentialRequestedType.SignIn)
        {
            e.Submit(login, password, false);
        }
    }

private void SigninCallback(IAsyncResult ar)
    {
        if (ar.IsCompleted == true)
        {
            try
            {
                ((LyncClient)ar.AsyncState).EndSignIn(ar);
            }
            catch (RequestCanceledException re)
            {
                throw re;
            }
        }

    }

private void InitializeCallback(IAsyncResult ar)
    {
        if (ar.IsCompleted == true)
        {
            object[] asyncState = (object[])ar.AsyncState;
            ((LyncClient)asyncState[0]).EndInitialize(ar);

            //_ThisInitializedLync is part of application state and is 
            //a class Boolean field that is set to true if this process
            //initialized Lync.
            _ThisInitializedLync = true;
        }
    }

登录+密码是正确的,因为我可以在UI上与他们进行登录。

当被抑制的UI问题只发生。

我试过很多东西,我现在很绝望。

c# wpf skype-for-business lync-client-sdk
1个回答
0
投票

请检查SkypeForBusiness的版本。如果是2016年则发生因ModernAuthentication在客户端和租户office365启用。

如果ModernAuthentication被启用,LyncSDK是不是有足够的能力来处理ModernAuth的SDK不支持微软并没有计划升级SDK。

© www.soinside.com 2019 - 2024. All rights reserved.