Understanding Resource files in SharePoint 2010 – Tutorial

SharePoint defines two kinds of resource files: runtime resources (also called application resources) and provisioning resources. Application resources are used within the normal execution of a SharePoint application. SharePoint also distinguishes between application resources used in normal web applications and those used in Central Administration. Provisioning resources, on the other hand, are used when provisioning elements. You use them within features, site definitions, and list definitions. This means you need to be aware of the deployment and usage scenarios.

Provisioning Resources

Provisioning resources are used to localize solutions. This includes
• Descriptions for solutions, features, Web Parts, lists, sites, and so on
• Options presented in choice fields (SPFieldChoice controls)
• Base names of files used in the solution, such as "images" and "template"
• String resources used in the definition files

Resources encapsulate and abstract data from logic and design. This makes sense in larger projects involving many developers. Resources are mainly, but not exclusively, used for localization.

Resource Locations

Resource files in SharePoint are located in different folders, including these:
• C:\Inetpub\wwwroot\wss\VirtualDirectories\\App_GlobalResources\
• $SharePointRoot$\14\Resources\
• $SharePointRoot$\14\CONFIG\Resources\
• $SharePointRoot$\14\CONFIG\AdminResources\
• $SharePointRoot$\14\TEMPLATE\FEATURES\\Resources\

The target folder you use depends on what kind of resource you want to deploy. Every type of resource has its own folder. Provisioning resources are part of either a solution package or a feature and they land in these folders:

• $SharePointRoot$\14\TEMPLATE\FEATURES\\Resources\Resources..resx
• $SharePointRoot$\14\TEMPLATE\FEATURES\\Resources\
• $SharePointRoot$\14\Resources\

Every feature uses the resources file located in its Resources folder. You can, however, use another resource file or even shared resources. To share resource files you have to put them in the 14\Resources\ folder. This is the default option that is used when you add an item of type Global Resource File to your current solution. Site definitions and list definitions also get their resources from this folder.

Application resources can appear in these folders:
• $SharePointRoot$\14\CONFIG\Resources\
• C:\Inetpub\wwwroot\wss\VirtualDirectories\\App_GlobalResources\

Application resources are located in the CONFIG\Resources folder. For a web application to use those resources, they must be copied to their own App_GlobalResources folder. This is standard practice for global resources in any conventional ASP.NET project. On creation of the web application, the resources are initially copied to the App_GlobalResources folder. When you add new resources to the CONFIG\Resources folder, the resources need to be copied to existing web applications. You can do this
manually or use the stsadm command copyappbincontent. Alternatively, you can automate this by including the following in your FeatureActivated event in your feature receiver.