首页 > 解决方案 > 如何为本地化创建和加载 resource.dll?

问题描述

我正在开发一个在运行时翻译菜单的功能。从下面的代码生成了一个dll,但我不知道如何使用它。我编译时已经嵌入了一些资源 dll 文件,它运行良好。

  1. 生成 *.resx 文件。

     using (ResXResourceWriter writer = new ResXResourceWriter(fullPath))
     {
         writer.AddResource("Key1", "Test1");
         writer.AddResource("Key2", "Test2");
         writer.AddResource("Key3", "Test3");
         writer.Generate();
     }
    
  2. 从 *.resx 生成 *.resource 文件。

     ProcessStartInfo info1 = new ProcessStartInfo("ResGen.exe", fullPath)
     Process.Start(info1);
    
  3. 从 *.resource 生成 dll。

     ProcessStartInfo info2 = new ProcessStartInfo("al.exe", $@"/t:lib /link:{path}{resourcefileName}.resources /culture:en /out:{resourcefilepath}.resources.dll");
     Process.Start(info2);
    

现在,我怎样才能加载这个结果?

标签: localizationresources

解决方案


推荐阅读