We are using the following code to set the input language on the operating system:
InputLanguageManager.Current.CurrentInputLanguage = initialCulture;
It works on development pc, but on production pc Current is null.
InputLanguageManager.Current is implemented as follows:
public static InputLanguageManager Current
{
get
{
if (InputMethod.Current.InputLanguageManager == null)
InputMethod.Current.InputLanguageManager = new InputLanguageManager();
return InputMethod.Current.InputLanguageManager;
}
}
InputMethod.Current is implemented as follows:
public static InputMethod Current
{
get
{
InputMethod inputMethod = (InputMethod) null;
Dispatcher dispatcher = Dispatcher.FromThread(Thread.CurrentThread);
if (dispatcher != null)
{
inputMethod = dispatcher.InputMethod as InputMethod;
if (inputMethod == null)
{
inputMethod = new InputMethod();
dispatcher.InputMethod = (object) inputMethod;
}
}
return inputMethod;
}
}
MSDN says InputMethod can be null, when there is no active input method.
I dont understand that. Does anyone else?