In our LOB-application we implemented a simple plugin-system using reflection. Potential plugin-dlls are scanned for types that implement a certain interface and if found are instantiated using Assembly.CreateInstance(). The instantiated type has a method that returns a FrameworkElement (WPF) for display in the UI.
Our problem: when displayed in the UI, the FrameworkElement will use the default culture for localization.
The apps culture may differ from the OS-culture and is set within the OnStartup()-event of the app, by setting
CultureInfo info = new CultureInfo(language);
Thread.CurrentThread.CurrentCulture = info;
Thread.CurrentThread.CurrentUICulture = info;
Every directly referenced assembly in the project will happily return correctly localized resources (e.g. error messages from backend or license-service).
How can we apply a specific culture when dynamically loading assemblies/instantiating types using reflection?
Aucun commentaire:
Enregistrer un commentaire