Home All Groups Group Topic Archive Search About

Satellite/Resource DLL not recognized (Basic 2005)

Author
9 Nov 2006 12:13 AM
SomeDude
Hi group,


For some strange reason my custom resource-dll's is not recognized. I have
created a new DLL based on a translated RESX-file but my testapplication
will only return values from the embedded project-resx. Read on for the
full description.

This has been puzzling me for hours so if anybody can help please do
because this is driving me crazy ;)

TIA,

    SomeDude


Full description:

When I run my testapplication the first popup confirms that the
CurrentUICulture is indeed nl-NL but the second popup then shows "English"
(as defined in the embedded resx) instead of "Nederlands" which is the
value defined in my generated DLL.

I have added an embedded Resourcefile (Strings.resx) added to my project
which I intend to use as the default resourcefile.

I have created a customized resource-dll based by doing the following:
* I copied "String.resx" to a separate directory and renamed it to
"Strings.nl-NL.resx"
* I ran the command "resgen Strings.nl-NL.resx Strings.nl-NL.resources"
to create a resource-file
* I then compiled the DLL by running the command "al /t:lib
/embed:Strings.nl-NL.resources /culture:nl-NL /out:Strings.resources.dll"
* I copied the generated DLL (Strings.resources.dll) to the handmade
subdirectory "nl-NL" in the applicationdirectory


=== Here's my test-application ===================================

Imports System.Resources
Imports System.Threading

Public Class Form1
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim resourceManager As ResourceManager = New ResourceManager("MultiLang.Strings", GetType(Form1).Assembly)
        My.Application.ChangeUICulture("nl-NL")
    MsgBox("CurrentUICulture = "+ Thread.CurrentThread.CurrentUICulture.Name.ToString)
        MsgBox(resourceManager.GetString("TESTKEY"))

    End Sub
End Class

==========================================================

Author
9 Nov 2006 9:17 AM
SomeDude
One step further but still an error.

I have made some changes to the AL command and now at lease the dll is
loaded when I run the testapp:

- the name of the DLL had to be "MultiLang.resources.dll" instead of the
wrongly assumed "Strings.resources.dll"
- some extra info about the namespace had to be added
to get picked up by the application ("MultiLang.Strings")

Here's the new AL command that I used:
al /t:lib /out:MultiLang.resources.dll /v:1.0.0.8 /c:nl-NL
/embed:Strings.nl-NL.resx,MultiLang.Strings.nl-NL.resources,Private


When I run the app and view the Debug Window "Modules" I can see that the
DLL is being loaded so that's the good news.
The bad news is that I now get an error on the following line (attempting
to read the testvalue from the DLL):

Line: MsgBox(resourceManager.GetString("TESTKEY"))
Error: Stream is not a valid resource file


Anybody have any ideas why this is happening?


Thanks a million,

   SomeDude



On Thu, 09 Nov 2006 01:13:36 +0100, SomeDude wrote:

Show quote
> Hi group,
>
>
> For some strange reason my custom resource-dll's is not recognized. I have
> created a new DLL based on a translated RESX-file but my testapplication
> will only return values from the embedded project-resx. Read on for the
> full description.
>
> This has been puzzling me for hours so if anybody can help please do
> because this is driving me crazy ;)
>
> TIA,
>
>     SomeDude
>
>
> Full description:
>
> When I run my testapplication the first popup confirms that the
> CurrentUICulture is indeed nl-NL but the second popup then shows "English"
> (as defined in the embedded resx) instead of "Nederlands" which is the
> value defined in my generated DLL.
>
> I have added an embedded Resourcefile (Strings.resx) added to my project
> which I intend to use as the default resourcefile.
>
> I have created a customized resource-dll based by doing the following:
> * I copied "String.resx" to a separate directory and renamed it to
> "Strings.nl-NL.resx"
> * I ran the command "resgen Strings.nl-NL.resx Strings.nl-NL.resources"
> to create a resource-file
> * I then compiled the DLL by running the command "al /t:lib
> /embed:Strings.nl-NL.resources /culture:nl-NL /out:Strings.resources.dll"
> * I copied the generated DLL (Strings.resources.dll) to the handmade
> subdirectory "nl-NL" in the applicationdirectory
>
>
> === Here's my test-application ===================================
>
> Imports System.Resources
> Imports System.Threading
>
> Public Class Form1
>     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
>
>         Dim resourceManager As ResourceManager = New ResourceManager("MultiLang.Strings", GetType(Form1).Assembly)
>         My.Application.ChangeUICulture("nl-NL")
>     MsgBox("CurrentUICulture = "+ Thread.CurrentThread.CurrentUICulture.Name.ToString)
>         MsgBox(resourceManager.GetString("TESTKEY"))
>
>     End Sub
> End Class
>
> ==========================================================
Author
9 Nov 2006 9:52 AM
SomeDude
OK, problem solved,

I narrowed things down to syntax-errors in the al and resgen commands.
It seems that for satellite-dll's to work in VB "strongly typed resource
classes" have to be generated. Beware of the underscores in the al-syntax,
they are essential for getting things to work.

Good resgen-command:
resgen Strings.nl-NL.resx Strings_nl_NL.resources /str:vb

Good AL-command:
al /t:lib /out:MultiLang.resources.dll /v:1.0.0.1 /c:nl-NL /embed:Strings_nl_NL.resources,MultiLang.Strings.nl-NL.resources,Private

Now just copy the fresh dll to the subdir of your programroot and done,
"Nederlands" appears in the Messagebox.


WOOHOOO ;)


If I have time I'll do an article on some site.

   Bravo_Kernel


On Thu, 09 Nov 2006 10:17:41 +0100, SomeDude wrote:

Show quote
> One step further but still an error.

> I have made some changes to the AL command and now at lease the dll is
> loaded when I run the testapp:
>
> - the name of the DLL had to be "MultiLang.resources.dll" instead of the
> wrongly assumed "Strings.resources.dll"
> - some extra info about the namespace had to be added
> to get picked up by the application ("MultiLang.Strings")
>
> Here's the new AL command that I used:
> al /t:lib /out:MultiLang.resources.dll /v:1.0.0.8 /c:nl-NL
> /embed:Strings.nl-NL.resx,MultiLang.Strings.nl-NL.resources,Private
>
>
> When I run the app and view the Debug Window "Modules" I can see that the
> DLL is being loaded so that's the good news.
> The bad news is that I now get an error on the following line (attempting
> to read the testvalue from the DLL):
>
> Line: MsgBox(resourceManager.GetString("TESTKEY"))
> Error: Stream is not a valid resource file
>
>
> Anybody have any ideas why this is happening?
>
>
> Thanks a million,
>
>    SomeDude
>
>
>
> On Thu, 09 Nov 2006 01:13:36 +0100, SomeDude wrote:
>
>> Hi group,
>>
>>
>> For some strange reason my custom resource-dll's is not recognized. I have
>> created a new DLL based on a translated RESX-file but my testapplication
>> will only return values from the embedded project-resx. Read on for the
>> full description.
>>
>> This has been puzzling me for hours so if anybody can help please do
>> because this is driving me crazy ;)
>>
>> TIA,
>>
>>     SomeDude
>>
>>
>> Full description:
>>
>> When I run my testapplication the first popup confirms that the
>> CurrentUICulture is indeed nl-NL but the second popup then shows "English"
>> (as defined in the embedded resx) instead of "Nederlands" which is the
>> value defined in my generated DLL.
>>
>> I have added an embedded Resourcefile (Strings.resx) added to my project
>> which I intend to use as the default resourcefile.
>>
>> I have created a customized resource-dll based by doing the following:
>> * I copied "String.resx" to a separate directory and renamed it to
>> "Strings.nl-NL.resx"
>> * I ran the command "resgen Strings.nl-NL.resx Strings.nl-NL.resources"
>> to create a resource-file
>> * I then compiled the DLL by running the command "al /t:lib
>> /embed:Strings.nl-NL.resources /culture:nl-NL /out:Strings.resources.dll"
>> * I copied the generated DLL (Strings.resources.dll) to the handmade
>> subdirectory "nl-NL" in the applicationdirectory
>>
>>
>> === Here's my test-application ===================================
>>
>> Imports System.Resources
>> Imports System.Threading
>>
>> Public Class Form1
>>     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
>>
>>         Dim resourceManager As ResourceManager = New ResourceManager("MultiLang.Strings", GetType(Form1).Assembly)
>>         My.Application.ChangeUICulture("nl-NL")
>>     MsgBox("CurrentUICulture = "+ Thread.CurrentThread.CurrentUICulture.Name.ToString)
>>         MsgBox(resourceManager.GetString("TESTKEY"))
>>
>>     End Sub
>> End Class
>>
>> ==========================================================

AddThis Social Bookmark Button