如何访问另一个程序集的.resx?
我有一个程序集,其中包含一个Messages.resx,其中包含GUI消息的字符串,如是,否,确定,取消,打开等。我的项目引用此程序集。 我该如何使用它们?
在资源编辑器中,只需将资源标记为public
资源。 默认情况下,访问修饰符是internal
。 然后你可以正常使用它。
如果公开它不是一个选项,那么使用InternalsVisibleTo
程序集级别属性。
使用ResourceManager类
// Retrieve the resource. ResourceManager rm = new ResourceManager("Messages" ,Assembly.Load(assemblyPath)); string greeting = rm.GetString("Greeting");
希望这可以帮助