Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Internationalization / March 2005

Tip: Looking for answers? Try searching our database.

Localized strings in dynamically loaded assemblies not retrieved

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben Cline - 26 Feb 2005 08:03 GMT
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 a.s as [Assembly] =
system.Reflection.Assembly.GetAssembly(GetType(TestClass))
   Dim types() As Type = a.s.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 a.s 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
Ben
Ben Cline - 03 Mar 2005 10:43 GMT
Hi all,

Ok, I MAY have identified the problem. I am loading my assemblies in a new
AppDomain. I would like to change to UICulture in that domain but I can't
seem to find any way of doing that.

So new question, is there a way to set the Culture on a dynamically created
AppDomain?

Thanks
Ben.
Olivier Guinart [MS] - 17 Mar 2005 00:25 GMT
Hi Ben,

Have you tried the function AppDomain.CreateInstance ? There are 3
signatures for that function, and one takes the culture attribute as a
parameter.(http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemAppDomainClassCrea
teInstanceTopic3.asp?frame=true
)
Please take a look also at the remark from that topic.

It's unclear whether passing the culture will only help in parsing the
arguments, or if the satellite assemblies will be loaded as expected, but it
might be worth a try.

Otherwise, from your code, it looks like you're forcing the resources to be
loaded from the main assembly anyway, because you hard-coded the DLL name to
look for. So why would the resourcemanager class look for another assembly in
this case ? Have you tried Dim a.s as [Assembly] =
[Assembly].LoadFile(".\de-AT\test.resources.dll")? If that works, and you end
up being able to only load de-AT resources, then you'll have to build that
path string yourself.

Please let us know if this helps.

Lynne, Masayoshi, Olivier.
lynnedong@hotmail.com, msmayada@hotmail.com, olivierg@online.microsoft.com

-Please do not send email directly to this alias.  This alias is for
newsgroup purposes only
-This posting is provided “AS IS” with no warranties, and confers no rights.

> Hi all,
>
[quoted text clipped - 7 lines]
> Thanks
> Ben.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.