Access resx file from another project / assembly

I have a resource file in another project and you want to access, for example. lines from it. How can i do this?

+3
source share
1 answer

This is a very old question, but since it was not answered, and I just stumbled upon this problem, here are a few possible solutions:

Make sure the access modifier for resx is set to public!

Link to resx file

Look here

Then you either join the line directly with

var translatedString = Resources.NAME_OF_THE_STRING_IN_RESX_FILE; 

or through the ResourceManager

 var resourceManager = new ResourceManager("FULLY.QUALIFIED.NAMESPACE.NO.EXTENSION", Assembly.GetExecutingAssembly()); var translatedString = resourceManager.GetString("NAME_OF_THE_STRING_IN_RESX_FILE"); 

Direct access if you have a link to the project

 var translatedString = [FULLY.QUALIFIED.NAMESPACE.NO.EXTENSION].NAME_OF_THE_STRING_IN_RESX_FILE; 
+2
source

Source: https://habr.com/ru/post/953180/


All Articles