嵌入本地化资源.DLL的可执行在C#中?可执行、资源、DLL

由网友(友人圈)分享简介:我要我的程序多国语言。我已经成功地通过窗体的本地化和语言性的节目多国语言。它提出了一些.resx文件。然后,我删除非必要文件,如图像(他们是在所有的汉语语言一样)等从.resx文件。I want to make my program multilingual. I have successfully made the...

我要我的程序多国语言。我已经成功地通过窗体的本地化和语言性的节目多国语言。它提出了一些.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)
    ...
}
阅读全文

相关推荐

最新文章