Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'd like to set the title and description of a web part in the web part description file to a item in a global resource (located in App_GlobalResources). This is the snippet from my web part description file:

  <properties>
    <property name="Title" type="string">$Resources:MISResources, VideoWebPartTitle</property>
    <property name="Description" type="string">$Resources:MISResources, VideoWebPartDesc</property>
    <property name="ChromeType" type="chrometype">None</property>
  </properties>

It isn't working however. It does work when I use a resource file in the 14 hive (by mapping the Resources folder in my VS project and creating a specially targetted resource file for my project), however I'd like all of my localization resources located in a single file for tidiness. Is this possible or can the web part description file not reference global resources files?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The .webpart file resources can only exist in the 14 Hive, and there's a reason for this and it's to do with what thread is actually running to the file system to get the resource.

Whenever you use anything in the CAML Provisioning Framework (not official name), whether it's a Site Defintion, a Feature activation, a module pushing files out (like web parts) then this is processed by a thread that looks to the layouts virtual directly for resources.

Whenever you use a resource at page rendering time (within a webpart that's added to a page, in a page control, or in the masterpage) then the thread that handles this is looking in the App_GlobalResources directly in the IIS directory.

Why this is I've no idea, I can only assume it's historical, dating way back to WSSv2.

Unfortunately, this does mean you will have to duplicate the sources file. The plus side is that you can actually tell Visual Studio to deploy a file to the App_GlobalResource (by selecting the file in the Solution, go to Properties (F4), and choose from the Deployment Type, pick App_GlobalResources. You'll have to ensure that your file exists within at least an Empty Element folder or a Module Element folder).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.