Deploying .NET satellite assemblies in specific folder
Asked Answered
K

2

8

I'm working on a C# .NET application and I'm performing localization with resource files. I have culture specific resource files like:

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

After building, in the application root folder there are folders like fr-FR, ja-JP and so on.

Is it possible to move all localization resource files and folders into 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 place, it can't load resources. As i can see, application.config file need to be there also. And if i make app.config as embeded resource, it doesnt working.

Is there a way, how to make this without the .config file needed in same directory?

Thanks

Kew answered 15/12, 2011 at 22:8 Comment(2)
Is it a libray project, e.g. dll?Suffer
No, it's desktop application.Kew
L
11

By default the satellite assemblies are placed in the sub-directories directly below the executable file. If you want to move all the fr-FR, ja-JP and remaining folders for other cultures into the same folder Languages you can do it by adding the following entry into 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 and also in the directory or directories specified by the privatePath attribute of the probing element. You can specify any directories that exists below the application executable file. When specifying more than one sub-directory you need to delimit each one with a semicolon.

Lillielilliputian answered 15/12, 2011 at 22:26 Comment(1)
Does not work for me: there are 22 language folders (+ the lib folder) inside the build/release/ directory. Even with an empty build/release/ dir, right before you hit F6 to build the solution. Absolutely unnecessary. (just need 1 lang)Deferent
S
1

My ResX files under Properties are below:

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

I put the runtime information into application configuration file as described above but no change. still creating a tr-TR folder under the executable path, not under Languages folder. What possibly I'm doing wrong here? Thanks

<configuration>
...
<runtime>
...
</runtime>
</configuration>
Stoppage answered 18/8, 2012 at 14:37 Comment(1)
You need to move the folder yourself (I did it with a post-build step). The edit to your configuration settings only controls how extra assemblies are searched, not where they are written to.Thoroughfare

© 2022 - 2024 — McMap. All rights reserved.