donderdag 10 maart 2011

Can't reference Microsoft.SharePoint.dll in Windows Console Application

Some time ago I wanted to create a console application that communicates with SharePoint 2010 and will also run directly on the server. So no reason to use the SharePoint Client Object Model. Therefore, I wanted to make a reference to the Microsoft.SharePoint.dll but was unable to find it in the list. I tried to browse and this way I could add the reference but the Microsoft.SharePoint namespace was not recognized.

After some minutes I realized that the problem was the Target framework setting in the project's properties. Apparently, by default this is set to '.NET Framework 4 Client Profile'. Changing it to '.NET Framework 4' will allow you to add the reference and continue your work.

woensdag 9 maart 2011

SharePoint 2010 URL tokens

Just a quick post to inform you about some new URL parameters you can use within SharePoint 2010. The following list also contains some URL parameters that were also available in SharePoint 2007.

{ItemId} – ID (GUID) taken from the list view.
{ItemUrl} – Web-relative URL of the list item (Url).
{RecurrenceId} – ID of a recurrent item (RecurrenceID).
{SiteUrl} – The fully qualified URL to the site (Url).
{ListId} – ID (GUID) of the list (ID).
{ListUrlDir} – Server-relative URL of the site plus the list's folder.
{Source} – Fully qualified request URL.
{SelectedListId} – ID (GUID) of the list that is currently selected from a list view.
{SelectedItemId} – ID of the item that is currently selected from the list view.



dinsdag 8 maart 2011

Playing with the SharePoint 2010 ribbon

Via the SPRibbon object (! this object needs both the Microsoft.SharePoint and the Microsoft.Web.CommandUI DLL's) you can do all kinds of stuff with the SharePoint 2010 ribbon user interface.

Basically you can do something like this in the code of for example a web part:

SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);

and then call any method you want. For the ID's of the out of the box ribbons, check this file:

14/TEMPLATE/GLOBAL/XML/CMDUI.xml

SPRibbon methods not available

Some time ago I was experimenting with the SharePoint 2010 ribbon. Basically I wanted to hide some out of the box ribbon buttons. Via the SPRibbon class in the Microsoft.SharePoint.WebControls namespace you can get references to the ribbon and do all kinds of stuff.

Now the problem was that I did not have access to all the methods I would expect to see. After some searching I found out that you not only need a reference to Microsoft.SharePoint.dll but also to Microsoft.Web.CommandUI dll. Once done, you will see all the methods.

maandag 7 maart 2011

Custom errors and callstack are not shown for my SharePoint 2010 installation

We all know that by default SharePoint will not show you the complete details of an error when it occurs. In SharePoint 2007 you could easily configure this by changing some values in the web.config of the appropriate web application. Basically you would change the callstack, customerrors mode and debug values.

Now in SharePoint 2010 you would expect the same behaviour but changing just the web application's web.config will not show you the complete error details. For this you must change the values in these web.config locations:
  1. The web application
  2. 14/Config
  3. 14/Template/Layouts

You will want to change these properties:

customErrors mode="Off"
callstack="true" ... AllowPageLeveTrace="true"
compilation batch="false" debug="true"