How to access the localized language resource in another project for WPF?
Posted on 2013-10-11
I have created two projects:
This is a central repository for localized language:
BuildAction: Resource (I have also tried "Embeded Resource"
Access Modifier= Public
This is a view model, where we access the language resource programmically.
string key = "TestLabel";
ResourceManager rm = new ResourceManager("MyProject.Languages.Resources.MainWindow", Assembly.GetExecutingAssembly());
string sValue = rm.Get(key);
The build is successful. I can see the resource dll in the respective culture folders:
en-US, fr-FR and ja-JP
However, when I run the application, it threw the exception as follows:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyProject.Languages.Resources.MainWindow.resources" was correctly embedded or linked into assembly "MyProject.ViewModel" at compile time, or that all the satellite assemblies required are loadable and fully signed.
I have searched the web for possible answers. One of the suggestion is to compile the resource file to satellite assembly and link it to the applicaiton assembly. However, you need to run it by command line. That is not acceptable. So here are my questions:
(1) What is the correct approach to resolve this?
(2) What are the correct steps to handle it in VS2012? No command line.
Your answer will be highly appreciated. I wish I could give more than 500. If you request, I can split the question into few small questions for higher points.
Thank you very much indeed, and in advance.