14

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?

Louis Rhys
  • 34,517
  • 56
  • 153
  • 221

2 Answers2

18

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.

InBetween
  • 32,319
  • 3
  • 50
  • 90
2

Use ResourceManager Class

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

Hope this helps

Arsen Mkrtchyan
  • 49,896
  • 32
  • 148
  • 184
  • 1
    apparently this one is referring to .resource files, not .resx It throws an exception saying Messages.resource is not found – Louis Rhys May 26 '11 at 06:46
  • oops, did you found this(http://stackoverflow.com/questions/1222519/access-resx-resource-files-from-another-project)? – Arsen Mkrtchyan May 26 '11 at 09:48