How to attach to process before the application even starts?

Submitted by Robert MacLean on Wed, 03/30/2011 - 12:35

There is many ways to do debugging in Visual Studio, normally you just hit F5, compile & run the code with debugging. However sometimes you need to debug an executable you have already built or debug on another machine. I have mentioned this previously you can use the Attach to Process option to do debug MSCRM assemblies that exist on other machines and/or run by a executable you do not control.

image

This works great but recently I had an issue where the application would start and (silently) die within seconds, but only in test (never in dev). It just happened so quickly that I could not attach the debugger in time. So how can you debug that scenario?

Thankfully this is very easy, just go to your Visual Studio project settings and switch the Start Action to Start External Program, set the path to the executable and then hit F5!

image

What this will do is start the executable, attach the debugger and work with your code all for you – so no more racing against the attach to debugger options Smile