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.
webwires
source share