Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ResGen&AL和多个resx/resources文件的强名称附属程序集_Resources_Strongname_Satellite Assembly_Resgen_Al.exe - Fatal编程技术网

使用ResGen&AL和多个resx/resources文件的强名称附属程序集

使用ResGen&AL和多个resx/resources文件的强名称附属程序集,resources,strongname,satellite-assembly,resgen,al.exe,Resources,Strongname,Satellite Assembly,Resgen,Al.exe,无论出于何种原因,在将多个.resources文件编译成单个附属程序集.dll时,资源将不会显示。编译单个资源将起作用。以下是我使用的步骤 我们有一个名为ReportViewer的项目。此项目使用密钥MySnKey.snk签名。通过属性>签名>对程序集签名,选择强名称密钥文件:MySnKey.snk。 所有表单都已更新为Localizable=True 我们将所有resx文件处理为德语de-de。只有两个resx:MainForm.resx项目根目录和Resources.resx属性目录。 我有

无论出于何种原因,在将多个.resources文件编译成单个附属程序集.dll时,资源将不会显示。编译单个资源将起作用。以下是我使用的步骤

我们有一个名为ReportViewer的项目。此项目使用密钥MySnKey.snk签名。通过属性>签名>对程序集签名,选择强名称密钥文件:MySnKey.snk。 所有表单都已更新为Localizable=True 我们将所有resx文件处理为德语de-de。只有两个resx:MainForm.resx项目根目录和Resources.resx属性目录。 我有一个包含MainForm.de-de.resx和Resources.de-de.resx的文件夹,它们是这些文件的翻译版本。 使用resgen

>C:\Program Files\Microsoft SDK\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" MainForm.de-DE.resx
> "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
>C:\Program Files\Microsoft SDK\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
> "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
这将创建相应的.resources文件。现在要链接,我使用AL.exe:

>C:\Program Files\Microsoft SDK\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/模板:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe/keyfile:../MySnKey.snk

这将创建一个ReportViewer.resources.dll文件。如果我将其放入相应的子文件夹de de>ReportViewer.resources.dll中,就没有运气了。在Program.cs中,在调用Run之前

Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");
如果,我只包括主窗体,如

>C:\Program Files\Microsoft SDK\Windows\v6.0A\bin\AL/t:lib/embed:ReportViewer.MainForm.de-de.resources/culture:de/de/out:ReportViewer.resources.dll/模板:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe/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
请注意,此行中有多个/嵌入项。我使用的是逗号,它重命名了内部结构,这不是我想要的。在文件之间提供一个空格会产生一个看似无关的错误。请参阅,以获取一篇优秀的文章

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

> "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
> "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
请注意,这里没有进行重命名,输出只是MainForm.de-de.resources

> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx
> "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

请注意,重命名是在嵌入选项中的逗号之后完成的。第一个参数是.resources文件的文件名,逗号后是namespace.class.xx.resources的完全限定名。

在我知道可以在这里回答之前,我在帖子中回答了这个问题