dotnet internationalization:
I seem to be having a problem accessing the resource information in
dynamically loaded assemblies.
This best explained using an example.
I have a class called TestClass in a Test.dll. Using a TestClass.resx,
TestClass.de.resx and a TestClass.de-AT.resx I can compile to the following
structure.
..\Test.dll
..\de\Test.resources.dll
..\de-AT\Test.resources.dll
I can reference the dll directly in my VB program and get the texts, no
problem. I am using code a little like the following:
Dim ass as [Assembly] =
system.Reflection.Assembly.GetAssembly(GetType(TestClass))
Dim types() As Type = ass.GetTypes
Dim rm As ResourceManager
Dim resourceNameAttributes() As Object
For Each t As Type In Types
rm = New ResourceManager(t.FullName, t.Assembly)
resourceNameAttributes =
t.GetCustomAttributes(GetType(ResourceNameAttribute), True)
Dim resourceAtt As ResourceAttribute =
DirectCast(resourceNameAttributes(0), resourceAtt)
Debug.Writeline rm.GetString(resourceAtt.ResourceName)
Next
This works fine and I can see all my strings in the correct languages if I
do something like
Threading.Thread.CurrentThread.CurrentUICulture = New
System.Globalization.CultureInfo("de-AT")
the correct strings are retrieved.
The problem arises if I try to dynamically load the dll. I am doing
something like...
Dim ass as [Assembly] = [Assembly].LoadFile(".\test.dll")
'... The rest of the code is the same.
I get invariant resource infomation but the localized texts are not being
loaded. Is there some trick to this? How can I get the resourcemanager to
'know' there should be resource.dll's availible? Any ideas?
Thanks in advance