loading the right resources with Satellite Assemblies

N

Nader

I have the next simple code and it doesn't work:
ResourceManager gStrings = new ResourceManager("MyApp.Strings",
Assembly.GetExecutingAssembly());

//Get the user's language.
CultureInfo ci = new CultureInfo("es");
String str = gStrings.GetString("Username", ci);

I have two assemblies: one is the fallback String.resx and the other
one is Strings.es.resx
The problem is that str is getting it's string from the fallback and
it just doesn't want to get it from es-assembly
What am I doing wrong??

I would be greatfull if someone helps!
 
C

Clive Dixon

I once had a bizarre situation similar to this where I was banging my head
against a wall for ages - it worked for all classes in the system except
one. I tracked it down to a situation where I had an enum defined in the
same source file as the class using the resource manager - as soon as I took
that enum definition out of the same source file it worked. The presence of
the enum class was causing the compiler to generate an incorrect name for
the resource in the satellite assembly (but was correct in the main
assembly, so that fallback worked OK).

1) Where are you deploying your Strings.es.dll assembly? Is it in a
subdirectory called "es" under the directory containing the main assembly?
2) What does the name of the localised resource come out as in the satellite
assembly? (Open up your satellite Strings.es.dll assembly in ildasm.exe,
open up the Manifest section and look at the resource listings of the form
(for example) .mresource public 'Strings.es.resources')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top