Wednesday, August 15, 2007

Debugging in SharePoint

A recent project required us getting a good understanding of existing code and sorting out some bugs that we're occuring. In order to get a handle on what was occuring we had to setup debugging and add some expectation to the 'Unexpected Errors'!

The first step is to enable debugging in the web applications web.config by making the following changes;

<SafeMode MaxControls="200" CallStack="false" ...> <!-- Becomes -->
<SafeMode MaxControls="200" CallStack="true" ...>

<customErrors mode="On" /> <!-- Becomes -->
<customErrors mode="Off" />

<compilation batch="false" debug="false"> <!-- Becomes -->
<compilation batch="true" debug="true">

Kudos to Renaut Comte on this tip.

There is also a Killer post from Vince Rothwell with a whole bunch of tips for debugging SharePoint exceptions.

And of course, with features being the new black, there has been a feature created that you can simply install and activate on your server and see it surface in the Site Actions menu. "The feature provisions a simple page, which executes the System.Diagnostics.Debugger.Launch statement, causing an exception to be thrown and the debugger to be auto-attached." Very Cool!

Head on over to the SharePoint Team blog for more information on this;
http://blogs.msdn.com/sharepoint/archive/2007/04/10/debugger-feature-for-sharepoint.aspx

The feature is part of a bigger SharePoint 2007 Features pack available on CodePlex

technorati tags:, , ,

Blogged with Flock

No comments: