Строки нагрузки ресурса (в файле .resx) от другой сборки

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/59983

Вопрос

Мы стремимся постепенно перемещать пользовательские артефакты на новые решения (WSP), и я собираюсь с помощью строк ресурсов загрузки из XML / Code в оригинальной упаковке (XXX.Package.WSP).
файлы ресурсов теперь расположены вНовый пакет xxx.package.resources.wsp.

Оба сборки являются полными доверием / GAC развертываемыми.
Обе сборки подписываются с одним сильным файлом клавиш имени.

e.g.В функции .xml следующая ссылка:


ImageUrl="$Resources:NameOfConfigFile,FeatureImageUrl;"
.

приведет к исклюкому:


System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "XXX.Package.Resources.NameOfConfigFile.resources" was correctly embedded or linked into assembly "XXX.Package.Resources"
 at compile time, or that all the satellite assemblies required are loadable and fully signed.   
 at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
 at ...
 at ...
.

Может кто-нибудь, пожалуйста, пролите свет на то, как это достичь?

Нужно ли мне написать свой собственный experiectbuilder и использовать это вместо ресурса по умолчанию, или есть ли более стандартный путь?

Это было полезно?

Решение

Localization of feature.xml differs from localizing something else. As by Microsoft's reference, you have to create a special Feature resource file (which will be stored along with the feature) in order to do that:

Based on my experience, if you deploy your resources into "Resources" mapped folder (in 14 hive), they will also be available from feature.xml file.

Also if you deploy resources to the "Resources" mapped folder, you will be able to fetch them programmatically by using SPUtility.GetLocalizedString function. In this case, it obviously doesn't matter by which wsp the resources were deployed: once you have the resx file in "Resources" folder, it will be available via SPUtility.GetLocalizedString.

On the other hand, resources deployed into "Resources" SharePoint mapped folder are not easily accessible from aspx and ascx markup (i.e. they won't be deployed to App_GlobalResources). Though you can use App_LocalResources after some tricking.

If you're embedding resources into assembly, it's even a bit more tricky, though has it's own benefits.

As you can see, the topic is really vast, and particular solution tightly depends on your way of implementing localization. If you're interested in some other particulars, please don't hesitate creating separate questions. As of now, I can recommend some very good links for you to read:

  1. Localizing SharePoint Solutions (MSDN)
  2. Localization of Sandbox Solutions in SharePoint 2010 (MSDN) (actually any solution can be localized that way, this is embedded resources approach)
  3. Use App_LocalResources in SharePoint 2010 Visual Web Parts (post by my collegue, SharePoint MVP Alexey Sadomov)
  4. Provisioning resources to App_GlobalResources in SharePoint 2010 (post by SharePoint MVP Waldek Mastykarz)

By the way, you might also be interested reading about approach of packaging multiple projects into one WSP, so that you don't have a whole bunch of WSP's yet in the same time in Visual Studio they are separate projects: https://sharepoint.stackexchange.com/a/12105/1430.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top