C# EnvDTE DLL之间的冲突

C# EnvDTE DLL之间的冲突,c#,dll,reference,alias,visual-studio-addins,C#,Dll,Reference,Alias,Visual Studio Addins,我有一个visual studio的加载项,当用户单击右键菜单“单击”时,它会向用户项目添加一个配置选项,并在运行项目时执行以下操作: public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddI

我有一个visual studio的加载项,当用户单击右键菜单“单击”时,它会向用户项目添加一个配置选项,并在运行项目时执行以下操作:

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;

    events = _applicationObject.Events;
    dbgEvents = events.DebuggerEvents;

    if (!registered)
    {
        dbgEvents.OnEnterRunMode += new _dispDebuggerEvents_OnEnterRunModeEventHandler(DebuggerEvents_OnEnterRunMode);
        registered = true;
    }
    if ((connectMode == ext_ConnectMode.ext_cm_AfterStartup))
    {
        //add right click menu
    }
}
//...
//when click on the right click menu
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
    handled = false;
    if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
    {
        if (commandName == _addInInstance.ProgID + "." + PROJECT_COMMAND_NAME)
        {
            //...
            //add configuration option
            Solution2 sol = (Solution2)_applicationObject.Solution;
            var pro = sol.Projects.Item(1).Object;
            var tool = pro.Configurations.item(ConfigName).Tools("VCCLCompilerTool");
            //...

            handled = true;
            return;
        }
    }
}

...

void DebuggerEvents_OnEnterRunMode(dbgEventReason Reason)
{
    if (Reason == dbgEventReason.dbgEventReasonLaunchProgram || (Reason == dbgEventReason.dbgEventReasonGo && isLunchProgram))
    {
        //do something
    }
}

private EnvDTE.Events events;
private EnvDTE.DebuggerEvents dbgEvents;
//...
private AddIn _addInInstance;
private OutputWindowPane _outpuWindow;
pro.Configurations
中的配置属性存在于:

C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblys\EnvDTE.dll

但是当有对它的引用时,
DebuggerEvents\u OnEnterRunMode()
事件不会触发。 我将此引用替换为

c:\Windows\assembly\GAC\EnvDTE\8.0.0.0\uuu b03f5f7f11d50a3a\EnvDTE.dll

现在调用了事件,但Configurations属性未定义。 所以我加了两个

为了避免同一名称空间之间的冲突,根据和中的说明,我定义了

c:\Windows\assembly\GAC\EnvDTE\8.0.0.0\uuu b03f5f7f11d50a3a\EnvDTE.dll

作为X,并添加行
外部别名X,但问题是当我尝试编写

var tool = pro.X::EnvDTE.Configurations.item(ConfigName).Tools("VCCLCompilerTool");

我得到一个编译错误:

对象不包含“X”的定义,并且找不到接受类型为“object”的第一个参数的扩展方法“X”(是否缺少using指令或程序集引用?)

我该怎么办

var tool = pro.(X::EnvDTE.Configurations).item(ConfigName).Tools("VCCLCompilerTool");