Friday, October 17, 2008

Remote Debugging Sharepoint dll in vs2008

Hi There,

I have been playing with SharePoint from quite some time now. The incredible thing about SharePoint is all the stuff we find accidently. After few 100’s of such accidental findings I have decided to put it down in my blog. I am no expert. Just want to share what did and did not work for me.

My first blog is about the problem and solution for remote debugging. Remote debugging has always been evil necessity for me. Evil coz I have always faced issues. Step by step approach for setting remote debugging is given below
1) msvsmon.exe:- To establish the connection remote debugging monitor must running on the remote machine. Msvsmon.exe can be located at [Install path\Microsoft Visual Studio *\Common7\IDE\Remote Debugger\x86]. However in my case remote machine did not have vs2008. I copied the msvsmom.exe from my host system to the remote machine. It could be copied anywhere on remote server. I copied on the desktop.
2) Run the exe by double click. The exe will start a new named server.
3) In msvsmom.exe click on tool->permission. Add the user credential [domain\user] of the host machine. In my case it was my NTlogin.
4) On host machine make sure the code is compiled on debug mode
5) Copy the .dll and .pdb file to the remote machine.
6) Add the dll to gac and register the assembly in web.config for sharepoint. You may want to reset iis. I usually do.
7) In host machine attached process
  • Go to Debug->Attached
  • Set Transport-> Default
  • Set Qualified:- fully qualified name of the named server started by msvsmom.exe
8) Open Module window
  • Go to Debug->Windows->module
  • Look for your project assembly
  • Check the status of symbol
  • If its set to cannot find or open PBD file; right click on the assembly->Load assembly
  • In location type in the remote server file location of copied pdb file
  • Click ok
9) It should work now; It did for me.

ALso do make sure the following settings are done as well in site web.config

set configuration\SharePoint\SafeMode\CallStack attribute to "true."
set configuration\system.web\compilation\debug attribute to "true"
set configuration\system.web\customErrors\mode attribute to "Off."