How can I read inline .resx in different assemblies

I have several DLLs in my project that only contain a lot of .resx files as embedded resources. Resx files are placed in different folders in each project. The "Custom Tool Name Space" property for all is set for the namespace of each project. When I try to use ResourceManager

to get a string, I get an error that for example "MyTemplate.resources" was not found, but I only have "MyTemplate.resx" in the dll.

How can I access my resources?

new ResourceManager(typeof(MyTemplate.resx)).GetString("FirstNameTooltip");

      

As I said in the comment below, resources are dynamically changing. and I don't have direct access to its properties.

+1


source to share


2 answers


This is how I usually do:

string mystring = YourResourceNamespace.MyTemplate.FirstNameTooltip;

      

If you don't know the padding click on the .resx and double click on Designer.cs, then check the namespace, all keywords will be defined as a simple static variable using gettor, so just call them.



If the ressource is in one other project, just add it to your project to access them from your project.

I hope this helps

+1


source


First you need to download the assembly:

Assembly ressourceAssembly = Assembly.Load("ResourceAssembly");

      

(There are several problems you might have with this. Read about dynamic assembly loading).

Then create a resource manager:



ResourceManager myManager = new 
   ResourceManager("<default namespace>.<Resx-Folder>.<Resx-File>", ressourceAssembly);

      

Then load the line:

myManager.GetString("FirstNameTooltip");

      

0


source







All Articles