Visual Studio: auto attach to a process when the process is spawned

后端 未结 10 995
青春惊慌失措
青春惊慌失措 2020-12-04 13:47

I want to attach to a process(a.exe) as soon as it is spawned, is it doable with VS? I only know the name of the process. Actually what I want to accomplish is set a breakpo

相关标签:
10条回答
  • 2020-12-04 14:41

    I really liked Entrian Attach as suggested by @RichieHindle, but I also found this free tool that does something similar. It catches all processes started by the debugging process.

    Spawned Process Catcher: https://marketplace.visualstudio.com/items?itemName=Brubtsov.SpawnedProcessCatcher

    0 讨论(0)
  • 2020-12-04 14:44

    How about this: open project for a.exe in VS, set the breakpoints etc. Then open Project Properties for a.exe, Debugging tab, and set Command to c.exe. Then just hit Debug.

    Unfortunately I never did this with managed projects, so I can be off the mark here. However, that's how I would do it with unmanaged (C++) projects. I think managed debugger should support it too.

    0 讨论(0)
  • 2020-12-04 14:47

    You can also use gflags.exe util that comes with Windows Debugging tools, all you need to do is open gflags.exe then go to image file enter the process name (a.exe) press tab and check the debugger checkbox, in the TextBox enter the vs path with the option /debugexe (i.e. "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" /debugexe)

    The automatically visual studio will open once the process is running you can add your breakpoints and press Run.

    0 讨论(0)
  • 2020-12-04 14:48

    I have been looking for some way to do this when I launch a console application within an acceptance test.

    I found this today - https://blogs.msdn.microsoft.com/visualstudioalm/2014/11/24/introducing-the-child-process-debugging-power-tool/

    It's an add-on to visual studio, and it works a treat. When I debug an acceptance test (I use resharper test runner) and place a breakpoint within the app that gets launched, I can now debug the app in the same visual studio instance.

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