簡體   English   中英

Visual Studio 2010 加載項問題

[英]Visual Studio 2010 Add-In Problem

我剛剛創建了一個程序集和一個 Visual Studio 加載項,如下所示:

起初,大會

  • 文件 => 新項目
  • 新 Class 庫

在我將“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 方法中調用新的 class ,則不會發生任何事情。 (沒有調試斷點被觸發)

    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;
    }

但為什么? 問題是什么?

提前致謝!!

檢查“For - Testing”插件文件中的程序集標簽。
檢查它指向的文件夾以及該文件夾是否包含“ClassLibrary1.dll”。 我在這里遇到了類似(或相同)的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM