Tuesday, 6 January 2009

Remote Debugging a .NET app with Visual Studio 2008 (9)

This is where you need to debug an application in visual studio, but the process is running on some other machine (i.e. not on your local box). A good example is when a tester is running something and you want to connect to their box to debug it.

This in fact turned out to be a pretty painless process.

First on the machine where the app is running that you need to debug you need to run msvsmon.exe . I found this in

Program Files
\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86 .

This will bring up the "Visual Studio Remote Debugging Monitor".

More than likely you will be debugging a machine on your network. So goto Tools>Permissions, and add the user of the machine where visual studio is running.

Now run the application you intened to debug

Now in Visual Studio goto Debug>Attach to Process . In the box "Qualifier" , enter the machine name of where your application is running and hit enter.

A list of processes will appear in the "Available Processes" box below. On the other machine in the remote debugging monitor you will see a log that you have connected.

Select the process which corresponds to the app you want to debug from Available processes and click on attach. And that's it you are now in debug mode and you can set your breakpoints and whatever and debug your app in the usual way!

For more info look at this article from microsoft :

http://support.microsoft.com/kb/910448

3 comments:

  1. Nice - you posted this on my birthday.

    For bonus points, you can have your application start remotely when you press Visual Studio's green triangle button, just like normal. Under the Debug settings for the Project, you need to check "Use remote machine", and then under Start Options you need to launch the external program using a path that is local to the remote machine.

    ReplyDelete
  2. I attach the process fine, but when I debug I can't see the breakpoints or the code in solution explorer? Can someone tell me what I am doing wrong?

    ReplyDelete
  3. If you have recently upgraded a Visual Studio .NET 2003 ASP.NET application project or a Visual Studio 2005 Web Application project to a Visual Studio 2008 ASP.NET Web Application project you may have noticed the following popup. Needless to say this makes it a little more difficult to connect remotely to your project in order to run and debug it.

    ReplyDelete