programatically attaching Visual Studio debugger to Windows Mobile processes


  • Hello,

    I've been trying to programatically attach Visual Studio Debugger to a process in a windows mobile emulator.
    I read an article from online for recording Visual Studio macro, so I used it to see how VS macro looks like when I choose Tools/Attach To Process/Smart Device for WM5 emulator. I tried to emulate macros' code and here is my attempt at trying to at least retrieve the processes within the emulator.


    dteTwo = (EnvDTE80.DTE2)Marshal.GetActiveObject("VisualStudio.DTE.9.0");
    EnvDTE80.Debugger2 debuggerTwo = (Debugger2)dteTwo.Debugger; 
    Transport smartDevTp = debuggerTwo.Transports.Item("smart device");
    Processes smartDevProcesses = debuggerTwo.GetProcesses(smartDevTp, "USA Windows Mobile 5.0 Pocket PC R2 Emulator");

    This code works for retrieving desktop machine's processes, if I replace "smart device" with "default" for Transports.Item and put "" for 2nd parameter for GetProcesses. I'm getting 0x80004005 (is this same as HResult value E_FAIL for unspecified value ??) message for exception thrown at EnvDTE80.Debugger2.GetProcesses method with error code(HResult) -2147467259

    I tried solution from , but didn't help.
    I think I'm not using provided api correctly to retrieve mobile device/emulator's processes for programatically attaching process to VS debugger, but just couldn't figure out what I'm exactly not doing correctly =/

    I've been searching web and msdn for similiar question, but didn't find satisfying answer yet. I'll be greatul for any helpful advice.

    Monday, November 23, 2009 10:40 PM

All replies

  • Hello,

    Based on my test, we could get the Transport by calling, for example:
    Transport smartDevTp = debuggerTwo.Transports.Item(2);
    Will you please try this and let me know the result?

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Friday, November 27, 2009 9:27 AM
  • Thank you for suggestion. Sadly, I still get same error =( 
    It looks like getting transport is not the problem.
    I'm beginning to wonder the way I'm trying to retrieve Debugger2 object is causing
    the issue with GetProcess method.



    dteTwo = (EnvDTE80.DTE2)Marshal.GetActiveObject("VisualStudio.DTE.9.0");

    // is this correct way to get Debugger2 object ???
    EnvDTE80.Debugger2 debuggerTwo = (Debugger2)dteTwo.Debugger; 

    Anyway, thank you for your reply, and I'll continue to experiment and search for solution to my problem.
    Monday, November 30, 2009 10:53 PM
  • Yes that is the way to get the debugger object.
    Thursday, December 17, 2009 1:55 AM
  • I know this post is crazy old now but was wondering if you ever figured out how to make this happen.

    Thursday, September 6, 2018 2:16 AM