471,337 Members | 819 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Locating and matching resources in embedded and external resource files

I'm having trouble grasping how ASP.NET correctly locates resources.
There is plenty of documentation on this subject but some things are
not clear at all.

In my ASP.NET application, I have multiple web forms. When you compile
the application, it creates a DLL. If you view this DLL using ILDASM
(the manifest), it shows info about the resources stored in the DLL.
There is essentially an embedded resource "section" for each web form.
The namespace used in each web form plays an important name in how the
resource is named in the manifest. I call this a "section" because it
is obviously referring to where the resources are located and not the
actual resources stored there.

At this point, the resources stored in the DLL are the "embedded
resources". The default culture ID for the resources in the DLL is
english US (en-US). The name of the DLL is myApp.dll.

I also have an additional DLL that contains what I believe should be
the resources translated over into German. The name of DLL resource
file is
myApp.de-DE.resources.dll. I say "believe" because I have no way of
actually seeing the IDs of the resources in the original DLL. I assume
that Visual Studio.NET uses the name of the controls found on the web
forms as the ID in the resource. So I used these names as well as IDs
in the German resource file.

Finally, following the rules spelled out by Microsoft in their online
documentation, you create subdirectories within the bin directory for
resources and store the corresponding resource there.

To read resources within the web form I do the following:

Thread.CurrentThread.CurrentCulture = new
Thread.CurrentThread.CurrentUICulture =

Assembly assembly = Assembly.Load("myApp");
ResourceManager rm = new ResourceManager("myApp", assembly);
this.lblCompanyID.Text = rm.GetString("lblCompanyID");

I store the culture ID in the session and use it to set the current
culture so that the correct resource will get loaded.

When the culture is set to "de-DE", it will in fact load the correct
But when I set the culture to "en-US", it cannot find the resource. I
really can't really understand why it even should find the resource.
If the manifest indicated that resource in the english manifest was
MyNamespace.NameOfWebForm.resources, I can't understand where ASP.NET
even matches up resources. There doesn't appear to be any relationship

If I were to create my German resources in a file called
MyNamespace.NameOfWebForm.resources, it might work. But wait a second.
Is this to imply that for every web form there must be a corresponding
external resource file for the language you want to support? This
doesn't make any sense. I thought that it was possible to store all
resources for the entire ASP.NET application in one resource file
myApp.de-DE.resources.dll and ASP.NET will take care of locating the
corresponding resource in whatever resource is stored in the default
manifest. And since there are multiple resource sections in the
default assembly, doesn't it make sense that ASP.NET will know where
to look?

Johann Blake
Nov 18 '05 #1
0 2060

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Philipp Seidel | last post: by
5 posts views Thread by Marcus Ahlberg | last post: by
7 posts views Thread by Ken Allen | last post: by
1 post views Thread by Stefan Turalski \(stic\) | last post: by
1 post views Thread by D. Yates | last post: by
1 post views Thread by Sergei Shelukhin | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.