Wednesday, April 24, 2013

SharePoint Looking for Resource Files in Feature Path Instead of Hive or App_GlobalResources

We were getting series of log entries in the SharePoint log saying “Failed to open the file <Resource file path>” and “Failed to read resource file <Resource file path>”.

We had the correct resource files deployed in <14 hive>\Resources and App_GlobalResources folder of the Web application. But SharePoint was actually looking for the resource files in custom feature folder paths in the 14 hive.

04/23/2013 16:00:21.13 w3wp.exe (0x1120) 0x15B8 SharePoint Foundation          General                        b9y9 High Failed to read resource file "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\DE.Int.Base_GlobalListDefinitions\Resources\Resources.resx" from feature id "9a9dff4b-bf05-7db9-9e10-6ed3cbb5d958". 36db8de3-5278-47ea-ada5-23e50aae5047

04/23/2013   16:13:07.60   w3wp.exe (0x1FA8)   0x1918   SharePoint Foundation   General   b9y3   High   Failed to open the file 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\DE.Int. Base_GlobalListDefinitions\Resources\Resources.resx'. 0b97f720-de7b-4fbb-b4d2-65c842184855

Finally it turn out to that we have specified resources for feature titles and descriptions but we haven’t specify the optional "DefaultResourceFile" property of the feature to retrieve Feature XML resources.


Definition for DefaultResourceFile property in MSDN says:
Optional Text. Indicates a common resource file for retrieving Feature XML resources. If you do not specify a resource in the file, SharePoint Foundation looks by default in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATES\FEATURES\FeatureName\Resources\Resources. Culture.resx. However, if you want to provide a shared core resource file for all the Features in your application, you can specify an alternate file through which to access resources by using DefaultResourceFile. For example, if you set DefaultResourceFile="MyFile", SharePoint Foundation looks in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\Resources\MyFile. Culture.resx to retrieve localized resources for your Feature.

So our issue was fixed by specifying the appropriate resource file name in the feature properties.


No comments: