Visual Studio - Attach to process shortcut

后端 未结 12 731
情歌与酒
情歌与酒 2020-11-27 16:42

When I want to debug I have to do Debug->Attach to Process -> Look for a process in the list -> Attach.

I was wondering if I can create some kind of a shortcut to

相关标签:
12条回答
  • 2020-11-27 17:25

    VS extensions

    • Debug Attach Manager
    • ReAttach
    • Resurrect

    More: Search the VS Marketplace for "attach"

    Keyboard

    • The attach to process shortcut is Ctrl+Alt+P in Visual Studio 2005 and above. You can then press the first letter of the process name you want, e.g. w for w3wp.exe and it'll jump to that, then Enter to attach.
    • You can use the Alt key shortcut ALT+D,P to launch the "Attach to Process" window via Debug menu.

    Code

    • Add System.Diagnostics.Debugger.Launch() to your code

    Current release is VS2015 at time of writing.

    Go ahead and edit/extend this answer :-)

    0 讨论(0)
  • 2020-11-27 17:28

    This answer should work for Visual Studio 2010.

    I like having buttons to do this on my debug toolbar

    https://gist.github.com/1406827

    The gist contains a method for attaching to IIS (w3wp.exe) or ASP (aspnet_wp.exe) and also nunit (nunit-agent.exe). Instructions are included on how to add the macros to your debug toolbar.

    0 讨论(0)
  • 2020-11-27 17:34

    For Visual Studio 2017, 2019, there is a ReAttach extension available. Very handy.

    0 讨论(0)
  • 2020-11-27 17:38

    The easiest way to do this is to write a macro which finds the DTE.LocalProcess you wan to target and automatically attach. For example

    Public Sub AttachShortcut()
      For Each proc In DTE.Debugger.LocalProcesses 
        If proc.Name = "what you're looking for" Then
          proc.Attach()
          Exit Sub
        End IF
      Next
    End Sub
    

    Note: This Stack Overflow Question is related and has a sample you may find useful

    • Attaching to a child process automatically in Visual Studio during Debugging
    0 讨论(0)
  • 2020-11-27 17:38

    The shortcut is Ctrl+Alt+P in Visual Studio 2005 and above.

    0 讨论(0)
  • 2020-11-27 17:40

    Alt+Shift+P to reattach the last attached process.

    It works for me in Visual Studio 2017.

    0 讨论(0)
提交回复
热议问题