Visual Studio 2010的外接程序问题 [英] Visual Studio 2010 Add-In Problem

查看:201
本文介绍了Visual Studio 2010的外接程序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了一个大会和一个Visual Studio插件是这样的:

I just created a Assembly and a Visual Studio Add-In like this:

起初,组装


  • 文件=>新建项目

  • 新类库

在我已经改变了的Class1.cs文件的内容

After i have changed the content of the "Class1.cs" file to

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中添加 - 在

  • 单击通过向导

在我已经改变了连接的内容。 CS文件:

After i have changed the content of the "Connect.cs" file to:

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



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

But why ? What is the problem ?

在此先感谢!

推荐答案

检查大会在标签对于 - 测试插件文件
检查它指向的,如果该文件夹中包含ClassLibrary1.dll的文件夹。我在这里类似(或相同)的问题

Check Assembly tag in "For - Testing" addin file.
Check the folder it points to and if that folder contains 'ClassLibrary1.dll'. I had a similar (or identical) problem here.

这篇关于Visual Studio 2010的外接程序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆