culture specific string resource dll not working in .net compact framework when application is installed using cab file

我怕爱的太早我们不能终老 提交于 2019-12-10 19:19:13

问题


I have created a application with localization using visual studio 2008 and .net compact framework 3.5 on windows mobile 6.1. To achieve localization, I have used many resource file for this, one for each langauge :

StringResources.de-DE.resx

StringResources.es-ES.resx

StringResources.en-GB.resx

StringResources.fr-FR.resx

StringResources.nl-NL.resx

I also have a StringResources.resx file with default strings for fallback in case other culture not supported by my app is chosen.

I have also created a .cab file by using a "SmartDeviceCabProject" (vdproj type) to perform installation of this application on the device. (using msdn.microsoft.com/en-us/library/aa446504.aspx)

Here is the problem that I am facing: When I change the culture to anything other than the nl-NL, I always get default strings.

Please also note that when I copy paste the "bin" folder of the application into the device, all culture strings are seen. Only when application is installed via the cab file that the problem occurs.

Also if i remove the StringResources.nl-NL.resx file and only have

StringResources.de-DE.resx

StringResources.es-ES.resx

StringResources.en-GB.resx

StringResources.fr-FR.resx

as the culture specific resources and recreate the cab file, now see that when I change the culture to anything other than the fr-FR, I always get default strings. So only the last culture file is effective always.

Just to be sure I diffed the dlls that were installed in each of the culture folders via the cab file on the device : de-DE\Application.StringResources.dll

es-ES\Application.StringResources.dll

en-GB\Application.StringResources.dll

fr-FR\Application.StringResources.dll

nl-NL\Application.StringResources.dll

Strangely I found all the dlls are exact same. However if I diff the dlls present in the "bin" folder, they are found to be different.

Thus I believe that the .cab file build is causing the same DLL to be copied to each folder.

With the above explanation in mind, please help me with :

**1. What do I do to make the cab file install the proper DLLs to the folders?

  1. Is there any other way to place the correct dlls?

  2. IS there any other way to achieve localization?**


回答1:


This problem is registered as a bug in WizCab.exe: Smart Device CAB Project includes wrong localized resources.

I have found that the best way around the problem is to:

  1. Add post-build events to the projects with localized resources that copies the resources files to unique (file) names:

    copy "$(TargetDir)sv\$(TargetName).resources.dll" "$(TargetDir)sv\sv_$(TargetName).resources.dll"

    for each present language.

  2. perform a build and overwrite these unique resource files with an empty file - otherwise the visual studio GUI will not allow you to rename (step 4) the added files.

  3. Add the copied localized assemblies as files (right click on .cab-project and choose "View" -> "File System") under "Application Folder" to the correct localization folders instead of using references to project output.

  4. Rename the added assemblies in the "File System view" back to their original names ("YourProject.resources.dll".)

Not very nice but it works.



来源:https://stackoverflow.com/questions/4672752/culture-specific-string-resource-dll-not-working-in-net-compact-framework-when

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!