Pages

Jul 28, 2010

Remote Debugging SharePoint Code.....!

The other day I ran into a situation where I needed to debug an assembly that I had placed in the GAC of the SharePoint server and did not have Visual Studio installed on the SharePoint machine. I knew there were ways to attach to a process so I did a search to see if there was a way I could remotely attach to the process from Visual Studio running on my machine.

The process is pretty easy:

1. Locate the msvsmon.exe file located in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86. This file is located on the machine that has Visual Studio installed on it.

2. Copy this file to the machine that you want to debug the code on (the SharePoint machine).

3. Run the exe. This will create a small window on the server that says the remote debugging server is waiting.

4. In Visual Studio on your machine, select Tools -> Attach to Process.

5. Get the process ID for the SharePoint web app you want to debug. You can do this by running the iisapp command from the SharePoint server command line. This will list the AppIDs and the name of the Web applications running on your server.

6. In the Attach to Process dialog, in the Qualifier drop down select the browse button and browse for the SharePoint machine.

7. Once you have the machine, select the process name (w3wp.exe) and the ID that matches the Web app that you want to debug.

8. Click attach and start debugging.

No comments: