Enabling the developer dashboard programmatically in SharePoint 2010

This is a question that I received during the Egyptian community launch of SharePoint 2010 and Office 2010. The following snippet does the trick!

SPWebService contentService = SPWebService.ContentService;
           SPDeveloperDashboardSettings developerDashboard =
             contentService.DeveloperDashboardSettings;
           developerDashboard.DisplayLevel = SPDeveloperDashboardLevel.On;
           developerDashboard.Update();

The guy who asked me this question wanted to create a farm-scoped feature to easily toggle the developer dashboard instead of using Windows PowerShell or STSADM command line utility. He also promised to share his feature with me once he finishes it.

If you cannot wait and you want to do it yourself, it’s very easy thanks to Visual Studio 2010 and the new SharePoint project and item templates that ships with it. Just open up Visual Studio 2010, create an empty SharePoint project, add a farm-scoped feature, add an event receiver to the feature, copy the code above to the FeatureActivated method, deploy your solution and there you go!

130

 

1

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s