VS 2005 Automation using EnvDTE: Attach command status RRS feed

  • Question

  • Hi all,
    I'm working on VS 2005 plugin. My task is to attach MS VS 2005's debugger to several processes using EnvDTE and handle attached/not attached situations for each process.

    Here is attach code:

    for (int iProcess = 0; iProcess <= iProcessesCount; iProcess ++)
        	EnvDTE::ProcessPtr pProcess_tmp;
        	EnvDTE80::Process2Ptr pProcess;
        	pProcesses->Item(variant_t(iProcess), &pProcess_tmp); //it seems that index is one-based
        	pProcess = pProcess_tmp;
        		long pid;
        		if(pid == g_pTestProcessIds[i])

    But I can't figure out how to detect "successfully attached" or "not attached" situations.
    I tried RunMode detection using _dispDebuggerEvents:

       SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispDebuggerEvents), 1, OnEnterRunMode)
        SINK_ENTRY_EX(1, __uuidof(EnvDTE::_dispDebuggerEvents), 2, OnEnterDesignMode)

    But appeared that after attaching to first process, IDE switches to RunMode so this doesn't work for me.

    Also I've tried _dispDebuggerProcessEvents with checking Process2::get_IsBeingDebugged() inside:

        SINK_ENTRY_EX(1, __uuidof(EnvDTE80::_dispDebuggerProcessEvents), 1, OnProcessStateChanged)
        void __stdcall OnProcessStateChanged(EnvDTE::Process* NewProcess, EnvDTE80::dbgProcessState processState)
        	EnvDTE80::Process2Ptr pProcess = NewProcess;
        	VARIANT_BOOL debug_mode = VARIANT_FALSE;
        	if(debug_mode == VARIANT_TRUE)
        		m_pOutputWindowPane->OutputString(CComBSTR("\tDebugger Attached to process\n"));
        		m_pOutputWindowPane->OutputString(CComBSTR("\tDebugger is NOT Attached to process\n"));

    But appeared that after one process stops, other processes also stops and isDebugged works only for first process.

    Is there any legal way to detect attach procedure end?

    Tuesday, October 29, 2013 2:12 PM


  • Hello,

    Please take a look at the information from MSDN:

    "_dispDebuggerProcessEvents.OnProcessStateChanged Method  supports the .NET Framework infrastructure and is not intended to be used directly from your code.

    Microsoft Internal Use Only."

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 31, 2013 9:08 AM