Friday, October 12, 2007

Debugging in SharePoint

The following are the couple of things I found helpful while trying to fix an error in SharePoint.

To view the actual errors from the Sharepoint web Application with call stack rather than the custom error message do the following steps.
  • Open the web.config of the webapplication in Inetpub\wwwroot\wss\virtualdirectories\webapplicationfolder.
  • Set the CallStack attribute of the SafeMode element to “true”
  • Set customErrors mode = “Off”

If we are deploying a custom feature or a WebPart and its not giving the expected behavior, It’s not very easy to trace it SharePoint. I have found the following approach helpful.

  • In the code use Debug.Write() of System.Diagnostics Namespace to display status messages or values of variables
  • When the code is run in the web application, the values displayed using Debug.Write() can be viewed with a tool like Debug View
  • Set the debug Attribute of compilation element in web.config of the web application to “true” for the messages to be displayed in the debug view.

No comments:

Post a Comment