首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用带有多个resx /资源文件的ResGen & AL的强命名卫星程序集

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

Stack Overflow用户
提问于 2012-03-29 16:24:34
回答 1查看 1.3K关注 0票数 0

出于任何原因,当将多个.resources文件编译为单个附属程序集(.dll)时,资源将不会显示。编译单个资源将有效。下面是我用的步骤..。

  1. 我们有一个叫做"Report“的项目。该项目使用一个键进行签名,MySnKey.snk.
  2. All通过属性>签名>签署程序集,选择一个强名称密钥文件:MySnKey.snk.
  3. All窗体已更新为Localizable =True
  4. 我们将所有resx文件处理为DE。只有两个resx: MainForm.resx (项目根目录)和Resources.resx (属性目录)。
  5. I有一个包含MainForm.de-DE.resx和Resources.de-DE.resx的文件夹,它们是这些文件的翻译版本。使用resgen的
  6. ,"C:\Program \Microsoft\Windows6.0A\bin\ResGen“/compile Resources.de-DE.resx

ReportViewer.MainForm.de-DE.resources:\

"C:\Program \Microsoft\\v6.0A\bin\ResGen“/compile MainForm.de DE.resx

这将创建适当的.resources文件。现在要链接,我使用AL.exe:

/template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /

:"C:\Program \Microsoft\Windows\v6.0A\bin\AL“/t:lib /embed:ReportViewer.MainForm.de-DE.resources,ReportViewer.Resources.de-DE.resources /区域性:DE /out:ReportViewer.resources.dll /t:lib/keyfile:./mysnkey.snk

这将创建一个ReportViewer.resources.dll文件。如果我将它放置到适当的子文件夹DE-DE>ReportViewer.resources es.dll中,就没有运气了。在Program.cs中,在调用Run之前,我已经

代码语言:javascript
复制
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");

如果,我只包括类似于MainForm的

/template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /

:"C:\Program \Microsoft\Windows\v6.0A\bin\AL“/t:lib /embed:ReportViewer.MainForm.de-DE.resources /区域性:DE-DE /out:ReportViewer.resources.dll /out:ReportViewer.resources.dll /keyfile:../MySnKey.snk

显示适当的资源。

这让我很困惑。如果我将.resx文件添加到解决方案中,并进行编译,则输出dll工作正常,但我们试图避免将这些附属转换带到解决方案中。

没有生成错误,也没有创建文件,所以我不知道我没有做什么。

任何帮助都是非常感谢的。在运行AL.exe时,我比较了将文件添加到输出文件到输出文件时的输出dll之间的差异,它们都包含所有的翻译。

编辑以包含解决方案,因为我不能回答问题

显然,我被嵌入选项和它的用法搞混了。要正确使用AL.exe实用程序,我必须使用:

代码语言:javascript
复制
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" Resources.de-DE.resx ReportViewer.Properties.Resources.de-DE.resources

请注意上面添加了Properties命名空间。我以前没这么做过。

代码语言:javascript
复制
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx  ReportViewer.MainForm.de-DE.resources

注意,没有添加属性命名空间,因为MainForm只是在ReportViewer名称空间中。

代码语言:javascript
复制
> "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

注意,这一行中有多个/embed项。我用的是逗号,这个逗号重新命名了内部,这不是我想要的。在文件之间提供空间会导致(看似)不相关的错误。有关一篇伟大的文章,请参阅http://ondotnet.com/pub/a/dotnet/2002/10/14/local2.htm?page=2

为了完整起见,编写此脚本的另一种方法是

代码语言:javascript
复制
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" Resources.de-DE.resx

注意,这里没有重命名,输出只是Resources.de-DE.resources

代码语言:javascript
复制
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx

注意,这里没有重命名,输出只是MainForm.de-DE.resources

代码语言:javascript
复制
> "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

注意,重命名是在embed选项中的逗号后面完成的。第一个参数是文件名( .resources文件),逗号后面是完全限定名(Nampace.class.xx-XX.resources)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-12 16:31:35

在我知道我能在这里回答之前就在邮件里回答了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9929438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档