简体   繁体   English

Visual Studio 2010 加载项问题

[英]Visual Studio 2010 Add-In Problem

I just created a Assembly and a Visual Studio Add-In like this:我刚刚创建了一个程序集和一个 Visual Studio 加载项,如下所示:

At first, the assembly起初,大会

  • File => New Project文件 => 新项目
  • New Class Library新 Class 库

After i have changed the content of the "Class1.cs" file to在我将“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!");
        }
    }
}

And now, the Add-In现在,加载项

  • File => New Project文件 => 新项目
  • Visual Studio Add-In Visual Studio 加载项
  • Clicking through the Wizard单击向导

After i have changed the content of the "Connect.cs" file to:在我将“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;
        }
    }

If i call the new class from the Exec Method, nothing happens.如果我从 Exec 方法中调用新的 class ,则不会发生任何事情。 (No debug break point get fired) (没有调试断点被触发)

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

if not, it works!如果没有,它的工作原理!

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

But why?但为什么? What is the problem?问题是什么?

Thanks in advance!!提前致谢!!

Check Assembly tag in "For - Testing" addin file.检查“For - Testing”插件文件中的程序集标签。
Check the folder it points to and if that folder contains 'ClassLibrary1.dll'.检查它指向的文件夹以及该文件夹是否包含“ClassLibrary1.dll”。 I had a similar (or identical) problem here .我在这里遇到了类似(或相同)的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM