Louis Rhys
Louis Rhys

Reputation: 35637

How to access another assembly's .resx?

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?

Upvotes: 14

Views: 12123

Answers (2)

InBetween
InBetween

Reputation: 32740

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.

Upvotes: 18

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50712

Use ResourceManager Class

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

Hope this helps

Upvotes: 2

Related Questions