尝试在 VSIX 解决方案中的 Visual Studio 状态栏中显示动画时发生错误

问题描述

在我的 VSIX 解决方案中尝试在状态栏中显示动画时,我不断收到此错误

无法将类型为“System.Threading.Tasks.ContinuationResultTaskFromresultTask`2[System.Object,System.Object]”的对象转换为类型“Microsoft.VisualStudio.Shell.Interop.IVsstatusbar”

This is my method which I took from the official MS documentation

private void displayAnimation(bool start)
    {

        ThreadHelper.ThrowIfNotOnUIThread();

        IVsstatusbar statusBar = (IVsstatusbar)ServiceProvider.GetServiceAsync(typeof(SVsstatusbar));

        object icon;

        // Use the standard Visual Studio icon for building.
        icon = (short)Constants.SBAI_Build;


        if (start)
        {

           

            // display the icon in the Animation region.
            statusBar.Animation(1,ref icon);

            return; 

        }

        // Stop the animation.
        statusBar.Animation(0,ref icon);

    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)