Reputation: 23831
All, I have a localised WinForms application. I have created a facility where users are able to change the required culture/language of the application at runtime. To avoid doing anything fancy, when the use does want to change the culture they are prompted that the application must be restarted for the change in culture to take effect (reasonable as this is not going to happen often if at all). I then store the new language required as a string in one of my settings XML files ("de-DE", "en-US", "en-GB" et al.). Then when the application restarts, if required I switch to the required culture:
// Main constructor.
public SqlEditorForm(string[] args)
{
// Load settings.
username = Environment.UserName;
userSettings = UserSettings.Instance();
advUserSettings = AdvanceUserSettings.Instance();
CheckChangeCurrentCulture();
isInitialising = true;
InitializeComponent();
...
}
private void CheckChangeCurrentCulture()
{
//if (!Debugger.IsAttached)
// Debugger.Launch();
if (advUserSettings.DefaultCulture)
return;
else
{
CultureInfo culture = new CultureInfo(advUserSettings.CustomCultureString);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
}
Now when running in debug/release mode from VS2012, this mechanism works fine. However, when I install the application on (running Windows 7 (x86/x64)) various machines this mechanism no longer works, that is to say that the culture does not switch from the machines default EVER.
I have attached the debugger to the installed application and the code to change the culture is being invoked and the logic seems to be working and no exceptions are thrown, but the culture/language does not change. I have been though many questions on SO but cannot find an applicable one that covers this particular issue.
Why is this mechanism working from VS2012, but not for the installed application? What do I need to do in order to achieve my desired behaviour?
Thanks for your time.
Note, I have also tried replacing the call to CheckChangeCurrentCulture();
with:
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de-DE");
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE");
which also works within VS2012 (Debug and Release modes) but not with the installed application. I have also changed the machines culture Start -> Control Panel -> Region and Language to German ("de-DE") expecting the application and the .NET framework to detect I have that culture available and use it. This also failed for the installed application.
Upvotes: 1
Views: 1910
Reputation: 1300
Maybe on your production machines the sattelite assembly of the new culture cannot be loaded for some reason and hence your application falls back to the neutral culture.
Check with Microsoft sysinternals Process Monitor tool for unsuccessfull satellite assembly file accesses.
You an also check with .NET fuslog tool http://msdn.microsoft.com/en-us/library/e74a18c4.aspx
Upvotes: 1