将本地化资源 .DLL 嵌入到 C# 中的可执行文件中?
我想让我的程序多语言化。我已经通过表单的本地化和语言属性成功地使程序成为多语言的。它制作了一些 .resx 文件。然后我从 .resx 文件中删除了不需要的文件,例如图像(它们在所有语言中都是相同的)等。
问题是,例如,它还生成一个名为“en”的文件夹,在该文件夹中,另一个生成的文件名为“ProjectName.resources.dll”。
有没有办法将此资源文件嵌入到 .exe 中?将其添加到资源并将构建操作设置为“嵌入资源”也不起作用。
谢谢。
I want to make my program multilingual. I have successfully made the program multilingual via Form's Localizable and Language properties. It made some .resx files. Then I deleted non-needed files such as images (which they are the same in all langauges) etc from the .resx files.
The problem is, for example, it also generates a folder called "en" and in that folder, another generated file is called "ProjectName.resources.dll".
Is there anyway to embed this resource file to the .exe? Adding it to the resources and setting Build Action to "Embedded Resource" doesn't work also.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在.NET Framework 4 中,您可以将资源库嵌入到可执行文件中。
http://msdn.microsoft.com/en-us/library/system.appdomain。 assemblyresolve.aspx
只需创建相同的结构(使用本地化文件夹“lib/en”、“lib/de”)并嵌入它们。
In .NET Framework 4 you can embed resource library into executable.
http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx
Just create same structure ( with localized folders 'lib/en', 'lib/de' ) and embed them.
您不久前问过这个问题并且您已经接受了答案,但我仍然会尝试提供另一种方法。我遇到了同样的问题,这就是我解决它的方法:
我将 dll 作为资源添加到我的 C# 项目中,并将此代码添加到我的主方法(启动主 winform 的方法)中。
注意
:如果文件夹和语言 dll 丢失,这将再次创建它,因此您不必再关心将文件夹和 dll 与 exe 文件一起复制。如果你想让它完全消失,这当然不是正确的方法。
You've asked this question a while ago and you've already accepted an answer, but still I'll try to provide an alternative way. I had the same problem and this is how I solved it:
I added the dll as a Ressource to my C#-Project and added this code to my Main-Method (the one that starts your main winform).
}
Note: This will create the folder and language-dll again if it's missing, so you don't have to care anymore that you copy that folder and the dll with your exe-file. If you want it to be completely vanished this won't be the right approach of course.