Why can’t I detach the debugger from an app?

An interesting internal thread on debugging went by, and it was news to me, so figured I'd share.

In the VS2005 debugger, you can't detach from a running app (that is, stop debugging but leave the target process alive)  if you're debugging in mixed mode (native and managed simultaneously.)


Comments (8)

  1. Yaytay says:

    That’s a good question, what’s the answer?

  2. Seth McCarus says:

    AFAIK you could not do this is VC6 either, or VS2003 – even in native mode. So what is the reason for this?

  3. Matt Pietrek says:

    Don’t remember what the story with VS 2003 was (it’s been almost 2 years since I’ve used it.) The VS2005 debugger behavior, as given by a debugger dude:

    If you attach to your app, when you stop debugging you will automatically detach without killing the app.

    If you launch your app under the debugger, you can detach by choosing the Debug->Detach All menu item. Otherwise, stop debugging will automatically terminate the app.

  4. Andy-Pennell says:

    VC6 couldnt do it for Native because its release (in 1998) preceeded the OS support for Detach (ie XP).

    VS7.0 and later can do it for Native (Seth is mistaken).

    Nothing can do it for Mixed because the debugging services support in the CLR doesn’t include Detach support.

  5. Norman Diamond says:

    Ummm, is the answer going to be posted by anyone who knows the answer? In the VS2005 debugger, if you’re debugging in mixed native and managed mode, why can’t you detach?

  6. As Andy said, VS doesn’t support it because the CLR doesn’t support it.

    So then I guess the question becomes — why doesn’t the CLR support it? Interop debugging is hard, and it was implemented in a way that made detach too difficult to implement.

    The CLR is currently working on reimplementing interop debugging for a future version. With the new architecture, detach should be much more reasonable.

  7. Norman Diamond says:

    I swear Andy Pennell’s answer wasn’t displayed yet when I asked.

    Though actually I’m still confused. If the debugging services support in the CLR doesn’t include Detach support then even Managed (without mixing) wouldn’t be capable?

  8. Matt Pietrek noticed you can’t detach while interop-debugging (aka "mixed-mode") in VS. Short answer:…

Skip to main content