出于任何原因,当将多个.resources文件编译为单个附属程序集(.dll)时,资源将不会显示。编译单个资源将有效。下面是我用的步骤..。
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之前,我已经
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实用程序,我必须使用:
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" Resources.de-DE.resx ReportViewer.Properties.Resources.de-DE.resources请注意上面添加了Properties命名空间。我以前没这么做过。
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx ReportViewer.MainForm.de-DE.resources注意,没有添加属性命名空间,因为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注意,这一行中有多个/embed项。我用的是逗号,这个逗号重新命名了内部,这不是我想要的。在文件之间提供空间会导致(看似)不相关的错误。有关一篇伟大的文章,请参阅http://ondotnet.com/pub/a/dotnet/2002/10/14/local2.htm?page=2。
为了完整起见,编写此脚本的另一种方法是
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" Resources.de-DE.resx注意,这里没有重命名,输出只是Resources.de-DE.resources
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx注意,这里没有重命名,输出只是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注意,重命名是在embed选项中的逗号后面完成的。第一个参数是文件名( .resources文件),逗号后面是完全限定名(Nampace.class.xx-XX.resources)。
发布于 2012-10-12 16:31:35
在我知道我能在这里回答之前就在邮件里回答了。
https://stackoverflow.com/questions/9929438
复制相似问题