跟着网上的文章学习代码行数统计器(一)
--Visual Studio 2005插件开发
我看的地址是:
http://www.cnblogs.com/sifang2004/archive/2006/06/26/436128.aspx可是自己写的却有问题,在这个函数中:
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;            if (connectMode == ext_ConnectMode.ext_cm_Startup ||  
                connectMode == ext_ConnectMode.ext_cm_UISetup)
            {
                //如果是安装状态或是插件刚被启动的状态,则创建菜单 
                object[] contextGUIDS = new object[] { };
        
                CommandBars cmdBars = (CommandBars) 
                               _applicationObject.CommandBars;
                Commands2 cmd = (Commands2)_applicationObject.Commands;                Command cmdObj;
                //创建一个命名命令
                cmdObj = cmd.AddNamedCommand2(_addInInstance,
                    "PublishUserManage",
                    "添加用户管理代码",
                    "添加用户管理的代码",
                    true,
                    127,
                    ref contextGUIDS,
                    (int)vsCommandStatus.vsCommandStatusSupported + (int)
                        vsCommandStatus.vsCommandStatusEnabled,
                    (int)vsCommandStyle.vsCommandStylePictAndText,
                    vsCommandControlType.vsCommandControlTypeButton
                );                //菜单条对象和工具条对象都是CommandBar类型 
                CommandBar menuObj;
    
                //创建一个命令栏
                //**********************************
                // 就是这里出问题
                //***********************************
                menuObj = cmdBars.Add("Tes&t", 
                       MsoBarPosition.msoBarFloating, false,false);                cmdObj.AddControl(menuObj, 1);
            }
}代码中我说出问题的那行,在那篇文章里也是这么写的,可是我写的却有问题,已运行到这里,就报错:说参数错误。可是我在MSDN上找不到CommandBars.Add()这个函数的用法,奇怪了,大家来帮帮我........