【问题标题】:Visual Studio 2010 Add-In ProblemVisual Studio 2010 加载项问题
【发布时间】:2011-08-11 07:51:04
【问题描述】:

我刚刚创建了一个程序集和一个 Visual Studio 插件,如下所示:

首先是大会

  • 文件 => 新项目
  • 新类库

我将“Class1.cs”文件的内容更改为

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLibrary1
{
    public class Class1
    {
        public void Test()
        {
            Console.WriteLine("Wohooo!");
        }
    }
}

现在,插件

  • 文件 => 新项目
  • Visual Studio 插件
  • 点击向导

在我将“Connect.cs”文件的内容更改为:

public class Connect : IDTExtensibility2, IDTCommandTarget
{
...
    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {
    // Adding a button to thet tools menu
// i can provide the source if needed
    }           

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

如果我从 Exec 方法调用新类,则不会发生任何事情。 (没有调试断点被触发)

    public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled)
    {
        Action action = GetAction(CmdName);

        if (CmdName == "MyAddin2.Connect.SampleAddin2")
        {
            new ClassLibrary1.Class1().Test();             
            Console.WriteLine("");
        }

        Handled = true;
    }

如果没有,它可以工作!

    public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled)
    {
        Action action = GetAction(CmdName);

        if (CmdName == "MyAddin2.Connect.SampleAddin2")
        {
            // new ClassLibrary1.Class1().Test();             
            Console.WriteLine("");
        }

        Handled = true;
    }

但是为什么?问题是什么 ?

提前致谢!!

【问题讨论】:

    标签: c# visual-studio visual-studio-2010 c#-4.0


    【解决方案1】:

    检查“For - Testing”插件文件中的程序集标签。
    检查它指向的文件夹以及该文件夹是否包含“ClassLibrary1.dll”。我遇到了类似(或相同)的问题here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-26
      • 1970-01-01
      • 2012-09-29
      • 2011-02-13
      • 2011-05-17
      • 2011-10-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多