Accessing resources

R

Rob

Hello

I am receiving this exception in my web application, using VS.NET
"Could not find any resources appropriate for the specified culture
(or the neutral culture) in the given assembly. Make sure
"mobile01.language.resources" was correctly embedded or linked into
assembly....."

My code looks like this:
ResourceManager rm = new ResourceManager( "mobile01.language.txt",
this.GetType().Assembly ) ;
mainMenu.Items[0].Value = rm.GetString("MM_Search") ;

I have followed all the instructions at
http://samples.gotdotnet.com/quickstart/howto/doc/createresources.aspx

Still, I'm fairly sure it's just a stupid mistake on my part, but I
can't find what, so any help would be appreciated. Here is what I have
done:

The resources file is added to the project and it's build type set to
"embedded resource"

I have inspected the contents of the assembly using Reflector and see
the resource container and it has the correct resources in it, with
the correct values.

Thanks in advance
Rob
 
M

Morten Wennevik

Hi Rob,

I think the resource file needs to be named as something ending with
..resources. The compiler is looking for "mobile01.language.resources".
However in code you use

ResourceManager rm = new ResourceManager( "mobile01.language",
this.GetType().Assembly )

without the "resources" ending.

Happy coding!
Morten
 
R

Rob

Morten Wennevik said:
Hi Rob,

I think the resource file needs to be named as something ending with
.resources. The compiler is looking for "mobile01.language.resources".
However in code you use

ResourceManager rm = new ResourceManager( "mobile01.language",
this.GetType().Assembly )

without the "resources" ending.

Happy coding!
Morten

Hi Morten, thanks for your reply, but unfortunately, this doesn't
work. I tried that already. The resource file *is* named
"language.resources", but I can't refer to it in the ResourceManager
constructor like that because that also produces an exception:
"ResourceManager base name should not end in .resources. It should be
similar to MyResources, which the ResourceManager can convert into
MyResources.<culture>.resources; for example,
MyResources.en-US.resources. "

Any further ideas would be very much welcomed :)
 
M

Morten Wennevik

If your resource file is named language.resources you should load
"language" in your resource manager.
If you have resource files called language.en-US.resources,
language.en-UK.resources and language.resources (the default file) you
only load "language". The resource manager will look for anything
beginning with "language" and ends with ".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