Inconvenient (Sandboxed) Custom ListDefinitions

Building custom SharePoint Online solution a List Definition is likely to be a SPI you would like to use. Sandboxed Solution look like a good way of deploying these definitions to your SharePoint Online environment, but are they?

Language When we deployed custom List Definitions we came across strange behavior accessing these lists. Suddenly the language changed from Dutch (nl-NL) to the default language (en-EN). Together with the help of MS we found some interesting information in the Logs. SharePoint was trying to access a resource file we didn’t deploy.

Localized Strings A SharePoint Feature comes with the property DefaultResourceFile. This property can be set with the Feature Properties. When empty SharePoint will try to get the resource from “%ProgramFiles%Common FilesMicrosoft Sharedweb server extensions14TEMPLATESFEATURESFeatureNameResourcesResources. Culture.resx” when a resource is requested by a Localized string. When you create a ListDefinition in Visual Studio the Schema.xml is being generated for you. The <List /> element contains an Attribute called Direction which is a localized string. Direction=”$Resources:Direction;”

The Localized string doesn’t refer to a default Resource file but instead it tries to get the Resource from the DefaultResourceFile. This results in an error when you are not deploying a Resource File to this location containing “Direction”.

Solutions This blogpost states that with SP1 the problem is resolved.http://www.mysticslayer.com/?p=211 However together with MS we found out that the error in the Log files still occurs in SharePoint Online. The easiest way to fix this is to replace the localized string in your schema.xml for a hardcoded value. MSDN explains what values can be used (http://msdn.microsoft.com/en-us/library/ms415091.aspx).

If you don’t want to choose this option for some reason, according to MS you can also choose to reference the Core Resource file Direction=”$Resources:core,Direction;”. This didn’t give me the error on premise, but obviously I couldn’t test it in Office 365 because I’m not able to check the Log files. I didn’t experience the language change as before so I assume this is a good option. Still the value in the core resource file for Direction is 0 which is not given as an option according to MSDN. My guess is that SharePoint sees this as “none”.