【问题标题】:How to access another assembly's .resx?如何访问另一个程序集的 .resx?
【发布时间】:2011-09-02 07:52:25
【问题描述】:

我有一个程序集,其中包含一个 Messages.resx,其中包含 GUI 消息字符串,例如是、否、确定、取消、打开等。我的项目引用了这个程序集。我该如何使用它们?

【问题讨论】:

    标签: c# .net resx


    【解决方案1】:

    在资源编辑器中,只需将资源标记为public。默认情况下,访问修饰符是internal。然后就可以正常使用了。

    如果无法将其公开,则使用InternalsVisibleTo 程序集级属性。

    【讨论】:

      【解决方案2】:

      使用ResourceManager Class

        // Retrieve the resource.
        ResourceManager rm = new ResourceManager("Messages" ,Assembly.Load(assemblyPath));
        string greeting = rm.GetString("Greeting");
      

      希望对你有帮助

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 2012-06-14
      • 1970-01-01
      • 2010-11-16
      • 2010-09-08
      • 2013-03-17
      • 2020-04-25
      相关资源
      最近更新 更多