Archives / 2008 / June
  • Debugging Running Processes in Visual Studio

    I recently was overhearing the conversation a colleague of mine was having about debugging a large Win Forms application.  It seems he was jumping through some major hoops to be able to debug the application.  Without getting too much into the architecture of the solution, it was instantiating other applications through a messaging system backend to communicate between apps.  In order to debug it, the team was using some code workarounds to kill processes, muddle around with new threads and processes, create a new process in debug which then impersonates some other process etc.  At least that’s what I think was happening. 

    This kind of debugging situation can be solved easily by using the "Attach to Process" debug functionality in Visual Studio.  I was surprised that the team didn't know about this feature so I wanted to post a quick "How-To" on using it so others can benefit from it.

    A couple of prerequisites must exist in order to attach to a running process.
    (1) The source must match the running application
    (2) The running application must have been compiled in debug mode

    It's fairly simple.  When you open up the source in Visual Studio, just navigate to the Debug menu and you'll find a menu item "Attach to Process". 


    When you select this, you will be presented with a window that shows all your running processes.  Simply click on the process you want to attach to and you're done. 


    If you're debugging a web application and using IIS to debug, you can even attach to the ASP.NET worker process "aspnet_wp.exe".  This will allow you to break on external requests to your web app.  If you're using the ASP.NET development server, you'll also find this on the list of processes you can attach to. 

    Hope this helps.



  • A "Friday the Thirteenths" Solution

    There was a recent post on LessThanDot to create a small application to find all the "Friday the 13th's" occuring in a range of dates.  Here is my simple solution to the challenge.  I also made it flexible enought to find any occurrence of a day / day of week combination within that range.  It runs surprisingly quick even when looking over the next 500 years.

    Also, if you like my color scheme, I've made it available for download here.