Expand the resource file to the App_GlobalResource folder when activated

Does anyone know the best way to deploy a resource file to the App_GlobalResource folder of a web application when the function is activated?

+6
resources sharepoint
source share
5 answers

So, as a final answer to this question, here is what we finally did to fully automate this process.

We were suggested to 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 actually put the files in the "resources" folder. So we just got access to the resources from there in the code as follows:

 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 entries from the resource file to the local dictionary. You must use RunWithElevatedPrivileges because the newly created "resources" folder is available only to the AppPool account.

+3
source share

Thanks to everyone for your answers, but the best solution for SharePoint 2010 is this:

  • Add New Item> Module
  • Copy (or) add resource files there
  • Change the Deployment Type property of each resource file to appGlobalResource
  • Change the Deployment Location> Path property to empty so that the resource file is deployed correctly to App_GlobalResources in your web application.

enter image description here

+8
source share

Application resource files cannot be deployed using the function unless you run any code and run the SharePoint timer job, which copies the files to the App_GlobalResources folder on each web interface server.

Instead, you should allow the SharePoint platform to deploy .RESX files to the App_GlobalResources folder on each server. Application resource files can be specified 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 a WSP solution package using STSADM or centralized administration, the SharePoint solution infrastructure starts a timer job that deploys these files in the App_GlobalResources folder of all the web applications to which you decided to deploy the solution.

+2
source share

For SharePoint 2010, you need to change the name of the XML node so that it is copied to the new App_GlobalResources folder instead of the Resource folder in the C: \ inetpub \ wwwroot \ wss \ VirtualDirectories \ 80 folder 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> 
+2
source share

We recently encountered the same problem when installing our farm. Unfortunately, adding ApplicationResourceFile entries in the manifest gets your resources only in the Resources folder.

While you can manually deploy resource files from resources to App_GlobalResources using stsadm -o copyappbincontent (to be released on each front-end server), we have finished creating a timer job for manually copying files, as indicated here :

0
source share

All Articles