Question

I'm working on an ASP.NET project with localized string resources which are located inside a Portable Class Library. It compiles ok, but at runtime the ResourceManager always just returns strings from the resource's base culture. It ignores the current thread's culture, it even ignores when I specify the culture directly.

For example, when I write

Localized.General.ResourceManager.GetString("Kommentar",CultureInfo.CreateSpecificCulture("en-GB"));

It returns the string for my base culture, which is German, even though it should obviously return the English language string.

If I move my resources into a regular .NET 4 library, the problem disappears.

In case itm matters, I'm using Visual Studio 2012, .NET 4 for the ASP.NET project and I'm targeting .NET 4 and Windows Store Apps in the PCL.

Any help would be greatly appreciated.

Thanks,

Adrian

Was it helpful?

Solution

In case someone else runs into the same problem: The problem was related to my base language, which is German. I wasn't aware that portable class libraries always come with the following default assembly attribute:

[assembly: NeutralResourcesLanguage("en")]

This overwrote my German base language setting in the main project, thus causing all problems described above.

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