简体   繁体   English

使用具有多个resx /资源文件的ResGen和AL的强命名卫星程序集

[英]Strong Named satellite assemblies using ResGen & AL with multiple resx / resources files

For whatever reason, when compiling multiple .resources files into a single satellite assembly (.dll) the resources will not show. 无论出于何种原因,将多个.resources文件编译到单个附属程序集(.dll)中时,资源都不会显示。 Compiling a single resource will work. 编译单个资源即可。 Here are the steps I used... 这是我使用的步骤...

  1. We have a project called "Report Viewer". 我们有一个名为“报表查看器”的项目。 This project is signed using a key, MySnKey.snk via Properties > Signing > Sign the assembly , choose a strong name key file: MySnKey.snk. 通过“属性”>“签名”>“签名装配”,使用MySnKey.snk键对项目进行签名,选择一个强名称密钥文件:MySnKey.snk。
  2. All forms have been updated to Localizable = True 所有表格已更新为Localizable = True
  3. We processed all the resx files into German de-DE. 我们将所有的resx文件处理为德文de-DE。 There are only two resx: MainForm.resx (project root directory) and Resources.resx (Properties directory). 只有两个resx:MainForm.resx(项目根目录)和Resources.resx(属性目录)。
  4. I have a folder with MainForm.de-DE.resx and Resources.de-DE.resx which are the translated versions of these files. 我有一个MainForm.de-DE.resx和Resources.de-DE.resx文件夹,它们是这些文件的翻译版本。
  5. Using resgen, 使用resgen,

    > "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\bin\\ResGen" /compile Resources.de-DE.resx ReportViewer.Resources.de-DE.resources >“ C:\\ Program Files \\ Microsoft SDKs \\ Windows \\ v6.0A \\ bin \\ ResGen” /编译Resources.de-DE.resx ReportViewer.Resources.de-DE.resources

    > "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\bin\\ResGen" /compile MainForm.de-DE.resx ReportViewer.MainForm.de-DE.resources >“ C:\\ Program Files \\ Microsoft SDKs \\ Windows \\ v6.0A \\ bin \\ ResGen” /编译MainForm.de-DE.resx ReportViewer.MainForm.de-DE.resources

This creates the appropriate .resources files. 这将创建适当的.resources文件。 Now to link, I use AL.exe: 现在链接,我使用AL.exe:

> "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\bin\\AL" /t:lib /embed:ReportViewer.MainForm.de-DE.resources,ReportViewer.Resources.de-DE.resources /culture:de-DE /out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk >“ C:\\ Program Files \\ Microsoft SDKs \\ Windows \\ v6.0A \\ bin \\ AL” / t:lib /embed:ReportViewer.MainForm.de-DE.resources,ReportViewer.Resources.de-DE.resources / culture: de-DE /out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk

This creates a ReportViewer.resources.dll file. 这将创建一个ReportViewer.resources.dll文件。 If I place it into the appropriate sub folder de-DE>ReportViewer.resources.dll, no luck. 如果将其放入相应的子文件夹de-DE> ReportViewer.resources.dll中,请不要走运。 In Program.cs, before Run is called, I have 在Program.cs中,在调用Run之前,我已经

Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");

IF, I only include the MainForm like 如果,我只包含MainForm之类的

> "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\bin\\AL" /t:lib /embed:ReportViewer.MainForm.de-DE.resources /culture:de-DE /out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk >“ C:\\ Program Files \\ Microsoft SDKs \\ Windows \\ v6.0A \\ bin \\ AL” / t:lib /embed:ReportViewer.MainForm.de-DE.resources / culture:de-DE /out:ReportViewer.resources。 dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk

The appropriate resources are displayed. 显示适当的资源。

This is quite confusing to me. 这让我很困惑。 If I add the .resx files to the solution, and compile, the output dll works correctly, but we are trying to avoid having to bring these satellite translations into the solution. 如果我将.resx文件添加到解决方案中并进行编译,则输出dll可以正常工作,但是我们试图避免将这些附属翻译带入解决方案中。

No errors are generated and the files are created so I'm lost as to what I'm not doing. 没有错误生成,没有创建文件,所以我对我没有做的事情迷失了。

Any help is greatly appreciated. 任何帮助是极大的赞赏。 I compared the differences between the output dll when adding the files to the solution to the output file when running AL.exe and they both contain all the translations. 我比较了在运行AL.exe时将文件添加到解决方案中的文件到输出文件时输出dll之间的差异,它们都包含所有翻译。

EDIT to include solution since I can't answer the question 编辑以包含解决方案,因为我无法回答问题

Apparently I got confused with the embed option and it's usage. 显然我对embed选项及其用法感到困惑。 To properly use the AL.exe utility, I had to use: 为了正确使用AL.exe实用程序,我必须使用:

> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" Resources.de-DE.resx ReportViewer.Properties.Resources.de-DE.resources

Notice above that the Properties namespace is added. 请注意,上面已经添加了Properties名称空间。 I had not done that before. 我以前没有做过。

> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx  ReportViewer.MainForm.de-DE.resources

Notice that no Properties namespace is added since MainForm is Simply in the ReportViewer namespace. 请注意,由于MainForm仅位于ReportViewer命名空间中,因此未添加任何属性命名空间。

> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL" 
/t:lib
/embed:ReportViewer.Properties.Resources.de-DE.resources
/embed:ReportViewer.MainForm.de-DE.resources 
/culture:de-DE /out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk

Notice that there are multiple /embed items in this line. 请注意,此行中有多个/嵌入项。 I was using the comma, which renames the internals and is not what I wanted. 我使用的是逗号,它重命名了内部结构,而不是我想要的。 Providing a space between the files gives a (seemingly) unrelated error. 在文件之间提供空格会产生(看似)不相关的错误。 See http://ondotnet.com/pub/a/dotnet/2002/10/14/local2.htm?page=2 for a great article. 有关精美的文章,请参见http://ondotnet.com/pub/a/dotnet/2002/10/14/local2.htm?page=2

For completeness, another way of writing this script would be 为了完整起见,编写此脚本的另一种方法是

> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" Resources.de-DE.resx

notice that no renaming is done here, the output is simply Resources.de-DE.resources 注意这里没有重命名,输出只是Resources.de-DE.resources

> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx

notice that no renaming is done here, the output is simply MainForm.de-DE.resources 注意这里没有重命名,输出只是MainForm.de-DE.resources

> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL" /t:lib
/embed:Resources.de-DE.resources,ReportViewer.Properties.Resources.de-DE.resources
/embed:MainForm.de-DE.resources,ReportViewer.MainForm.de-DE.resources
/culture:de-DE
/out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk

Notice that the renaming is done following the comma in the embed option. 请注意,重命名是在embed选项中的逗号后面进行的。 The first argument is the file name (the .resources file) and after the comma is the fully qualified name (namespace.class.xx-XX.resources). 第一个参数是文件名(.resources文件),逗号后面是全限定名(namespace.class.xx-XX.resources)。

在我知道我可以在这里回答之前,先在帖子中回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM