Saturday, January 14, 2012

Not able to debug SharePoint solution



There are cases when you would want to debug your SharePoint solution, but in vain, that debug pointer never gets caught. Reason, your symbols are not matching the binaries it was built with. The following are some of the common tasks we try during these times.

  • Delete the entire bin & obj folders.
  • Ensure that you are on Debug mode.
  • Do a Clean & Rebuild of the solution.
  • Put an System.Diagnostics.Debug.Assert(false); statement. During runtime, the process will throw an exception and then attach the w3wp process. Sometimes it is confusing which w3wp process to attach because there will always be more than one.
Inspite of the above, I have seen it doesn’t attach to the debugger some times.

What has worked consistently, until now is you can force the symbols (pdbs) to be loaded from the bin directory.
Tools > Options > Debugging > Symbols > Click on the Folder icon and specify the path to your bin/pdb directory.
If your build machine and the server machines are different then you can use this to cache the symbol files in the server or debugging machine.


The above steps would hold good for any .net projects. Hope this setting helps you in debugging next time.