Reputation: 9
I'm working on a .NET project and have encountered a scenario where i need to update a specific resource in a satellite assembly for the Japanese('ja-JP') culture without rebuilding the entire project. Here are the details:
My project uses resource file(Greeting.ja-JP.resx) for localization.
I have a satellite assembly for the Japanese culture('ja-JP') containing these resources.
I need to make a minor update to a single resource within the 'Greeting.ja-JP.resx' file.
Rebuilding the entire project is not an option due to project constraints.
I've tried manually updating the .resx file within VS and compiling it with Developer Command Prompt for VS 2019.
I then created a .resources file using resgen. The command is:
resgen Greeting.ja-JP.resx Greeting.ja-JP.resources
A satellite assembly is created using al.exe. The command is:
al -target:lib -embed:Greeting.ja-JP.resources -culture:ja-JP -out:Example.resources.dll
('Example' is the name of the project)
replaced the Example.resources.dll in in the output directory The directory:
Example
bin
debug
ja-JP
Example.resources.dll
Example.exe
Example.exe.config
Greeting.ja-JP.resx
Greeting.resx
App.config
Program.cs
after replacing the dll, the source code picks the default value for the string and not the updated one.
how to replace the existing satellite assembly for the Japanese culture without rebuilding the entire project.
Specific steps or commands I should use to accomplish this task.
Please provide a detailed walkthrough or explanation of the process, as I'm relatively new to working with satellite assemblies.
The source code:
string cultures = "ja-JP";
CultureInfo newCulture = new CultureInfo(cultures[cultureNdx]);
Thread.CurrentThread.CurrentCulture = newCulture;
Thread.CurrentThread.CurrentUICulture = newCulture;
ResourceManager rm = new ResourceManager("Example.Greeting",
typeof(Example).Assembly);
string greeting = String.Format("The current culture is {0}.\n{1}",
Thread.CurrentThread.CurrentUICulture.Name,
rm.GetString("HelloString")); // HelloString is the key in resx
MessageBox.Show(greeting);
Upvotes: 0
Views: 100