Using Resource files in SharePoint 2010 and Visual Studio 2010
To deploy Resource files with SharePoint solution / package, your solution must be not SandBoxed. So if you have choose SandBoxed Solution when you have created your project in Visual Studio, you should change it. To do it complete following steps:
- Open Solution Explorer in Visual Studio
- Select your SharePoint project
- In “Properties” tab set “Sandboxed Solution” to FALSE
Now you should create folder mapped to SharePoint Resources folder.
- Right click on your project in Solution Explorer
- “Add” –> “SharePoint Mapped Folder …”
- Choose “Resources” and click “OK” button
- Visual Studio will create folder Resources for you and sub folder inside it with your project title as folder name. You should delete it, because SharePoint doesn’t allow to deploy resource files inside subfolders.
- Right click on just created folder –> Add –> New Item
- Under “General” tab choose “Resources File”, rename it and click “Add”
Now you can add some entries to new resource file. When you will deploy your solution …
… deploying operation will automatically copy it into SharePoint Resources catalog (“C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Resources”)
* don’t name resource file with names which have already in SharePoint Resources catalog (otherwise you can loss SharePoint default functionality)
Now you can use your resources files where you need.
Fore example in Field-schema definition you can get value following way:
DisplayName="$Resources:PMS.ContentTypes,Contact_FirstName;"
PMS.ContentTypes is a resource file name
Contact_FirstName is a key inside resource file