How to access another assembly's .resx?

旧街凉风 提交于 2019-12-09 02:27:48

问题


I have an assembly which contains, among other things, a Messages.resx which contains strings of GUI messages such as Yes, No, OK, Cancel, Open, etc. My project references this assembly. How can I use them?


回答1:


In the resource editor just mark the resources as public. By default the access modifier is internal. Then you can use it normally.

If making it public is not an option then use InternalsVisibleTo assembly level attribute.




回答2:


Use ResourceManager Class

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

Hope this helps



来源:https://stackoverflow.com/questions/6134419/how-to-access-another-assemblys-resx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!