ResourceManager is unable to load resources in satellite assemblies

  • Thread starter Nils Erik Asmundvaag
  • Start date
N

Nils Erik Asmundvaag

Hello

I hope someone is able to help me with this frustrating problem.

I have a C# web project in Visual Studio .NET 2003. I want to support
Swedish and Norwegian texts and have put the texts in resource files
(.resx).

I build the project from the IDE without errors. A main assembly
(containing the Swedish texts) are created, and a resource assembly
containg the Norwegian texts are created in a subdirectory called no.

When I run the project, the ResourceManager is not able to get my
Norwegian texts from the satellite assembly. I have started the
project in debug mode, and I can see that the CurrentUICulture and
CurrentCulture is set to "Norwegian".

I have read the tutorials from Microsoft and other articles on the
net, but I haven't found any help.

N E Asmundvaag
 
K

Kai Brinkmann [MSFT]

Nils,

Your approach is correct in principle. I suspect there may be a problem with
the resource manager object, but it's impossible to tell without looking at
the code. Did you make sure to pass the name of the base resource file along
with the namespace reference to your ResourceManager constructor? This is
one of the most common mistakes. For example, if you were using the
namespace 'MyApp' and your main resource file (the one to be embedded in the
main assembly) were called 'AppStrings.resx', the constructor would look
something like this:

ResourceManager rm = new ResourceManager("MyApp.AppStrings",
Assembly.GetExecutingAssembly());

or if you are instantiating the resource manager on a web form called
WebForm1 which is part of your main assembly:

ResourceManager rm = new ResourceManager("MyApp.AppStrings",
typeof(WebForm1).Assembly);

After that, a simple call to

rm.GetString("<ResourceID>");

should do the trick and retrieve the appropriate resource from a satellite
assembly who's culture matches the CurrentUICulture.

Another common problem is related to the naming conventions required for the
RESX files themselves. The base resource file should not contain a specific
culture (e.g. AppStrings.resx), but the RESX files that go into your
satellite assemblies *must* contain the culture in their file names. So in
this example, your Norwegion resources would have to be named
AppStrings.no.resx. If you need more specific cultures, both
AppStrings.nn-NO.resx and AppStrings.nb-NO.resx would also be correct.
However, since you mention that a NO directory is created when you compile,
it sounds like your RESX file is probably named correctly already.

That's really all you should have to do. I'm sorry if I'm not telling you
anything new, but it's the best I can do without looking at your code.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Cosmin Marin

Hi,

I had the same problem with one of my apps and finally came with an
workaround (I'm not sure this is actually the 'official' thing to do, but it
solved my problem): give IUSR_<machine> full rights on the temporary ASP.NET
files (that is %SYSTEM%\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files). For whatever reason, at some point asp.net worker process tries to
create some folders there and it fails (from my observations, this is
related to the point when the resources come in the scene).

Cosmin
 
N

Nils Erik Asmundvaag

Cosmin Marin said:
Hi,

I had the same problem with one of my apps and finally came with an
workaround (I'm not sure this is actually the 'official' thing to do, but it
solved my problem): give IUSR_<machine> full rights on the temporary ASP.NET
files (that is %SYSTEM%\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files). For whatever reason, at some point asp.net worker process tries to
create some folders there and it fails (from my observations, this is
related to the point when the resources come in the scene).

Cosmin

Hello Cosmin,

This solved my problem. Thank you very much for the help!

Nils Erik
 

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