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:
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.