【问题标题】:Visual Studio 2008 Addin disapears after first clickVisual Studio 2008 Add In 在第一次单击后消失
【发布时间】:2011-11-23 21:52:29
【问题描述】:

我正在开发简单的 VS 2008 插件。
现在我只有基本自动生成文件的自动生成代码。
这是“TestsGenerator - For Testing.AddIn”文件:

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">
    <HostApplication>
        <Name>Microsoft Visual Studio Macros</Name>
        <Version>9.0</Version>
    </HostApplication>
    <HostApplication>
        <Name>Microsoft Visual Studio</Name>
        <Version>9.0</Version>
    </HostApplication>
    <Addin>
        <FriendlyName>CSUnit tests generator</FriendlyName>
        <Description>Generates tests for csUnit basing on TestingTable.xml file</Description>
        <Assembly>D:\Nova\dev\RecipeConverter\Sources\TestsGenerator\bin\TestsGenerator.dll</Assembly>
        <FullClassName>TestsGenerator.Connect</FullClassName>
        <LoadBehavior>0</LoadBehavior>
        <CommandPreload>1</CommandPreload>
        <CommandLineSafe>0</CommandLineSafe>
    </Addin>
</Extensibility>

当我在 F5 中运行项目时,我成功调试了代码。现在,这是我按 F5 后调用的函数列表:

构造函数()
OnConnect()

我在工具菜单中按下插件按钮:

OnConnect()
执行()

并且!!!按钮从工具菜单中消失!!!
有人能告诉我为什么会这样吗!?
谢谢你的到来。

【问题讨论】:

    标签: c# visual-studio add-in


    【解决方案1】:

    好的,事实上并非所有文件都是自动生成的,我从另一个插件中获得了其中的一部分。
    反正。虽然插件 Connect 类的全名是:TestsGenerator.Connect,但 QueryStatus 函数看起来像:

    public void QueryStatus(string commandName, vsCommandStatusTextWanted neededText, ref vsCommandStatus status, ref object commandText)
    {
        if (neededText == vsCommandStatusTextWanted.vsCommandStatusTextWantedNone)
        {
            if (commandName == "MyAddin2.Connect.MyAddin2")
            {
                status = (vsCommandStatus)vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
                return;
            }
        }
    }
    

    在我改变条件后,一切都开始工作了:

    if (commandName == "TestsGenerator.Connect.MyAddin2")
    

    【讨论】:

      猜你喜欢
      • 2011-12-05
      • 2014-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      • 1970-01-01
      相关资源
      最近更新 更多