Question

my resource files are located in a separate dll and all are marked as:

  • Build Action - Embedded Resource
  • Copy to Output Directory - Do not copy
  • Custom Tool - PublicResXFileCodeGenerator

Added a custom culture file: SiteLabels.en-customer.resx
Added the new culture en-customer as a Neutral language deriving from "en"

string culture = "en-customer";    
CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder = new        
CultureAndRegionInfoBuilder(culture, CultureAndRegionModifiers.Neutral);
CultureInfo cultureInfo = new CultureInfo(twoLetterISOLanguageName);               
cultureAndRegionInfoBuilder.LoadDataFromCultureInfo(cultureInfo);
cultureAndRegionInfoBuilder.Parent = cultureInfo;

cultureAndRegionInfoBuilder.CultureEnglishName = culture;
if (CultureInfo.GetCultures(CultureTypes.UserCustomCulture).Any(cult => cult.Name == culture))
{
    CultureAndRegionInfoBuilder.Unregister(culture);
}
cultureAndRegionInfoBuilder.Register();

built the project and saw that the satellite assembly en-customer\MyResources.resources.dll
wasn't created by VS

read all the answers in SO regarding this and didn't see any complaint about the issue, only suggestions on using the CLI to create the satellite assemblies.
The problem in this case is that the project referencing my resources dll wouldn't copy the new created satellite assembly to it's bin folder.

Was it helpful?

Solution

The Solution to this problem is Annoyingly simple:
You have to restart VS2010 after registering the new custom culture on the machine in order for it to generate the satellite assembly for the newly added custom culture.

Apparently VS2010 (hope MS fixed it in 2012) caches the cultures on the machine when it loads and won't create satellite assemblies for resx file of cultures that it doesn't know of. no warning, no error just silent death.
i used two instances of VS so registering in the first instance didn't affect the other.

hope this will help someone

p.s. in my resources dll, i created a .tt file that on every build will scan the resources and search for custom resources files to create a class with a variable that contains all the custom resources.
I use this variable to register my custom cultures + check in Application_Start if all the custom cultures are registered on the machine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top