Enabling the developer dashboard

by Tycho Bizot 29. November 2009 17:12

SharePoint 2010 has a new developer dashboard that, if enabled, renders a lot off usefull information below the normal site contents.
There are a few ways to enable the developer dashboard:

  • Stsadm –o setproperty –pn developer-dashboard –pv ondemand (or “on” or “off”)
  • using PowerShell
  • using the object model.

Since the webpart from my previous post "needed" to do something "usefull" i went for the last option.

Only a few lines off code are needed to enable/disable the dashboard. The OnDemand setting set below adds a small button to the top right side of your sharepoint side to toggle the dashboard on/off.

SPWebService ws = SPWebService.ContentService;
ws.DeveloperDashboardSettings.DisplayLevel =
SPDeveloperDashboardLevel.OnDemand;
ws.DeveloperDashboardSettings.Update();

Seems simple enough, but after pressing the Update button on my webpart i received a Security Exception, even if wrapped inside SPSecurity.RunWithElevatedPrivileges .

I started doubting myself and turned to Google who led me to a Technet post explaning that this is by design:

"NOTE:  This code will not work in a web part if the web part is hosted in any site except the central admin site.  We specifically check for and block that scenario because the developer dashboard is a farm-wide setting.  If you code it up in a web part and try to execute it in a non-central admin site, it will throw a security exception"

So i changed the target site on the webpart project and deployed it to the Central Administration, added the webpart and it worked right away.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

2010 | Software Development | SharePoint

Comments are closed

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen