嵌入本地化资源.DLL的可执行在C#中? [英] Embedding Localization Resources .DLL's to the Executable in C#?

查看:219
本文介绍了嵌入本地化资源.DLL的可执行在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要我的程序多国语言。我已经成功地通过窗体的本地化和语言性的节目多国语言。它提出了一些.resx文件。然后,我删除非必要文件,如图像(他们是在所有的汉语语言一样)等从.resx文件。

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.

的问题是,例如,它也产生一个称为文件夹en表示与该文件夹中,另一个生成的文件被称为ProjectName.resources.dll

The problem is, for example, it also generates a folder called "en" and in that folder, another generated file is called "ProjectName.resources.dll".

反正是有以嵌入此资源文件中的.exe?将它添加到资源和设置生成操作为嵌入的资源,不工作也。

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.

感谢。

推荐答案

在.NET Framework 4中,你可以嵌入资源库为可执行的。

In .NET Framework 4 you can embed resource library into executable.

http://msdn.microsoft.com/en-美国/库/ system.appdomain.assemblyresolve.aspx

只要创建相同的结构(与本地化的文件夹'的lib /恩','的lib /德),并嵌入。

Just create same structure ( with localized folders 'lib/en', 'lib/de' ) and embed them.

private static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) {
    AssemblyName MissingAssembly = new AssemblyName(args.Name);
    CultureInfo ci = MissingAssembly.CultureInfo;

    ...
    resourceName = "MyApp.lib." + ci.Name.Replace("-","_") + "." + MissingAssembly.Name + ".dll";
    var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)
    ...
}

这篇关于嵌入本地化资源.DLL的可执行在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆