Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Add New Item > Module
Copy (or) Add your resource files there
Change "Deployment Type" property of each resource file to appGlobalResource
Change "Deployment Location > Path" property to empty so the resource file deploys properly to "App_GlobalResources" under your web application
So, as a final followup to this question here is what we finally did to completely automate this process.
We did, as was suggested, use the ApplicationResourceFile element in the manifest file.
<?xml version="1.0" encoding="utf-8"?>
<Solution SolutionId="{185E973C-3A10-4e2a-9E0F-DC14414551F9}"
xmlns="http://schemas.microsoft.com/sharepoint/"
DeploymentServerType="WebFrontEnd">
<ApplicationResourceFiles>
<ApplicationResourceFile Location="yourappname.resx"/>
<ApplicationResourceFile Location="yourappname.en-US.resx"/>
</ApplicationResourceFiles> ...
</Solution>
This did in fact put the files into the "resources" folder. So, we simply accessed the resources from there in code like so:
string appPath = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath);
ResourceManager resX = ResourceManager.CreateFileBasedResourceManager("ResourceFileName", appPath + "resources", null);
SPSecurity.RunWithElevatedPrivileges(delegate()
AddResource(resX, "DefaultTextBoxLabelText");
We run this code in the constructor and add the entries from the resource file into a local dictionary. You must use RunWithElevatedPrivileges because the new "resources" folder that is created is only accessable by the AppPool account.
Application resource files cannot be deployed via a feature unless you execute some code and start a SharePoint timer job that copies the files to the App_GlobalResources folder on each Web front-end server.
You should instead let the SharePoint solutions framework deploy the .RESX files to the App_GlobalResources folder on each server. You can specify application resource files as follows in the manifest.xml file of your WSP solution package:
<?xml version="1.0" encoding="utf-8"?>
<Solution SolutionId="{185E973C-3A10-4e2a-9E0F-DC14414551F9}"
xmlns="http://schemas.microsoft.com/sharepoint/"
DeploymentServerType="WebFrontEnd">
<ApplicationResourceFiles>
<ApplicationResourceFile Location="yourappname.resx"/>
<ApplicationResourceFile Location="yourappname.en-US.resx"/>
</ApplicationResourceFiles>
</Solution>
When you deploy the WSP solution package using STSADM or Central Administration, the SharePoint solutions framework will start a timer job that deploys these files to the App_GlobalResources folder of all the Web applications you decided to deploy the solution to.
–
–
–
For SharePoint 2010 you need to change the XML node name so it will copy to the new App_GlobalResources folder instead of Resource folder in C:\inetpub\wwwroot\wss\VirtualDirectories\80
MSDN link: http://msdn.microsoft.com/en-us/library/ms463158.aspx
Example:
<Solution SolutionId="{8a2f91f2-db85-4eb3-8e7c-330f05246e1a}"
DeploymentServerType="WebFrontEnd"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ApplicationResourceFiles>
<App_GlobalResourceFile Location="yourResourceFile.resx"/>
</ApplicationResourceFiles>
We recently ran into the same issue on our farm installation. Unfortunately, adding ApplicationResourceFile entries in the manifest only gets your resources to the Resources-folder.
While you can manually deploy the resource files from Resources to App_GlobalResources with stsadm -o copyappbincontent (must be issued on every front end server), we ended up creating a timer job to manually copy the files, as outlined here:
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.