I had to write a little .NET app here that uses Office automation (for instance, to create Tasks directly in Outlook). One of the things I need to test is how the app behaves in case Outlook is not installed. Since I have Outlook installed in all my machines, I couldn’t really test that. I decided to use a VirtualPC image that only has Windows XP and the .NET Framework installed on it.
The next I wanted to do was to run a Remote Debugging session, running Visual Studio on my host (development) computer, and attaching the debugger to the application that’s running inside the VPC. I want to describe what I had to do to make that work, so that I don’t forget. Obviously, there may be better ways of doing it, but what I’m putting here is as much as I know as of now. 🙂
The most useful information I’ve used came from the How To: Set Up Remote Debugging page on MSDN.
First, I had to share set a shared folder on my VPC image, pointing the following folder on the host computer: Install path\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86.This folder contains the msvsmon.exe file (Remote Debugging Monitor), which has to be running on the remote computer (the VPC in this case) so to allow for the debugger to be attached to it.
I’ve also disabled the firewall both on my host machine and on the VPC. I didn’t have the time to go mess with the permissions to get things to go through, so I just disabled it (since the computers are behind the company’s firewall, I’m not concerned about security in this case).
Another thing I had to do was to add the VPC to our domain.
I then do a Run As… on the msvsmon.exe file, and execute it with my domain account (the same one I’m running as on the host computer).
I set the options on that tool by specifying a server name and "Windows Authentication" as the Authentication mode:
The monitor was then up and running on the VPC:
Next I ran my little .NET app on the VPC. I’ve also did a "Run as…" and ran it as my domain account.
With all that in place, I went in Visual Studio on the host computer, opened the source code for the .NET app, clicked Debug -> Attach to Processs on the menu, typed in the Qualifier (more on this in a moment), selected the process, and clicked Attach:
The Qualifier on the "Attach to Process" dialog must be the name of the server started by Msvsmon on the host:
That’s it. I’ve set breakpoints, and as I click stuff on my app running in the VPC, I can step through the code on my host computer.
I haven’t done much with remote debugging before. I like this option of deploying an app to a clean VPC image, and then debug it remotely using my dev machine as the host.