.net-4.0visual-studio-2012windows-server-2012attach-to-process

Attach visual studio to a short lived process


I have a console application that dies very quickly, and upon inspecting the code, I can't tell exactly where it'll die (I've basically narrowed it down to a 10 line radius) so that I further debug it.

For reasons I won't go into, I can't execute the process from VS (I have the binaries, source, and pdbs though, but I can't build outside of the build server's environment), and would like to attach to the process... but when I start the process, it dies much sooner than I could ever hope to refresh the attach to process dialog.

Ideas?


Solution

  • One possibility for doing this is to use any existing Visual Studio project and specify the application as the application to debug. The steps (in Visual Studio 2010) are:

    Then it should be possible just to start debugging (e.g., F5 or Debug\Start Debugging).

    Another option that might be a bit quicker if you have the debugging tools installed would be to use WinDbg.exe. It would avoid needing to use a Visual Studio project. You can open the executable, specify command line parameters, etc. and then type g<ret> in the command line to fire it up.