Deploying .NET satellite assemblies in a specific folder

I am working on a C # .NET application and I am localizing with resource files. I have resource files for specific crops, for example:

  • MyResource.resx;
  • MyResource.fr-FR.resx;
  • MyResource.ja-JP.resx;

After creating the application, there are folders like fr-FR , ja-JP , etc. in the root folder of the application.

Can I move all files and folders of localization resources to the same folder, for example Languages ?

Update 1:

I solved this with the code below. It seems that when I copy the application to another location, it cannot load resources. As I can see, the application.config file should also be there. And if I create app.config as an embedded resource, it does not work.

Is there any way how to do this without the .config file needed in the same directory?

thanks

+6
source share
2 answers

By default, satellite assemblies are placed in subdirectories directly below the executable file. If you want to move all fr-FR , ja-JP and other folders for other cultures to the same Languages folder, you can do this by adding the following entry to the application configuration file:

 <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="Languages"/> </assemblyBinding> </runtime> </configuration> 

This will indicate that when searching for assemblies, the CLR should search in the default locations, as well as in the directory or directories specified by the privatePath attribute of the privatePath element. You can specify any directories that exist under the application executable. When specifying more than one subdirectory, you need to delimit each semicolon.

+7
source

My ResX files in the Properties section are below:

  • Resources.resx
  • Resources.tr-TR.resx

I put the runtime information in the application configuration file as described above, but without changes. still creating the tr-TR folder by the executable path, and not in the Languages ​​folder. What am I possibly doing wrong here? Thanks

 <configuration> ... <runtime> ... </runtime> </configuration> 
+1
source

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


All Articles