You have created a neat SharePoint feature that works great. But in the logs files several errors pop up as soon as you deploy the new feature, complaining about a Localized resource token ‘Direction’. You haven’t created such a key in your resources files, so what’s up?
The log files may look like this:
Failed to open the file 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\...\Resources\Resources.en-US.resx'.
#2006e: The specified path "" does not exist.
Failed to read resource file "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\...\Resources\Resources.en-US.resx" from feature id "guid".
Failed to open the language resource for guid keyfile Resources.
Failed to open the file 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\...\Resources\Resources.resx'.
#2006e: The specified path "" does not exist.
Failed to read resource file "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\...\Resources\Resources.resx" from feature id "guid".
Failed to open the language resource for guid keyfile Resources.
Localized resource for token 'Direction' could not be found for file with path: "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\...\List1\schema.xml".
Analyzing the error takes us back to the definition of a list in the feature. In the file schema.xml, that Visual Studio generated while creating the List Definition, we can find the Direction key. (If you wonder what this parameter does, read more)
List xmlns:ows="Microsoft SharePoint"
Title="List1"
FolderCreation="FALSE"
Direction="$Resources:Direction;"
Url="Lists/List1"
BaseType="0">
So why is this generated code causing errors?
Because there is no resources file specified in the call to the Direction key, SharePoint will look in the default places where you can place your resources files in the following order (given that your language is US-English):
- A file called Resources.en-US.resx in the feature folder. (E.g. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features…\Resources\Resources.en-US.resx)
- A file called Resources.resx in the feature folder. (E.g. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features…\Resources\Resources.resx)
How can you solve this?
There are 3 options to fix this problem.
- Make sure that in your resources file, Resources.resx (with its variants of languages that you want), there is a ‘Direction’ Key defined. (Possible values: LTR, RTL, none)
- Fill the “DefaultResourceFile” property of your Feature with the name of the file of Resources that you want to use. This file must be in the path: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Resources
- Change the generated Schema.xml file. In the example given it would be: Direction = “$Resources: core, Direction;” In this way, we indicate that the Direction key is in the file Core.resx (in the 14\Resources, it’s the default SharePoint resources file)
There is a fourth option that is a hybrid between option 2 and 3. You can specify core as “DefaultResourceFile” in your feature properties.