1

We developed an application that loads specific .dll files which are then used as plugins. The app itself has multiple .resx-files which are used for localization.

Titles.resx
    Titles.de-DE.resx
    Titles.it-IT.resx

These files are loaded via Prism and LightInject

_container.RegisterSingletonFluent<TitlesLocalizer>();

public class TitlesLocalizer : LocalizerBase
    {
        public TitlesLocalizer()
        {
            ResourceManagerStringLocalizerFactory factory = new ResourceManagerStringLocalizerFactory(new OptionsWrapper<LocalizationOptions>(new LocalizationOptions()), new NullLoggerFactory());
            Localizer = factory.Create(typeof(Properties.Titles));
        }
    }

    public class TitlesLocalizer<T> : LocalizerBase<T>
    {
        public TitlesLocalizer()
        {
            ResourceManagerStringLocalizerFactory factory = new ResourceManagerStringLocalizerFactory(new OptionsWrapper<LocalizationOptions>(new LocalizationOptions()), new NullLoggerFactory());
            Localizer = factory.Create(typeof(T));
        }
    }

The localization of the app itself works as expected. All Plugins come with their own localization resources which are loaded via the generic localization:

_container.RegisterSingletonFluent<TitlesLocalizer<Properties.Titles>>();

The problem is, that inside the plugin, only the neutral language is being loaded. I checked the culture via breakpoint and it's still the one i want to use (German for example). I don't know what prevents the correct localization, so maybe someone got an idea what I do possibly wrong. Thanks in advance for any help! PS: If you need more code, just tell me. I will provide as much as I am allowed to

EDIT1: After testing a lot, I found the issue. When building the plugin project, it creates folders for "de-DE", "it-IT", ... . Inside there are the localization dlls. The Plugin itself will be copied to the apps build directory under "App/Plugins/PluginX". The problem is, that the app can only load the localization files, if they are inside "App/de-DE/".

So is there a way to load those .dll files, even if they are inside a subfolder like "App/Plugins/PluginX/de-DE/" ?

DirtyNative
  • 2,553
  • 2
  • 33
  • 58
  • 1
    Do the satellite assemblies for de-DE and it-IT languages present? – Pavel Anikhouski Feb 04 '20 at 07:28
  • Your answer helped me finding the problem. I added an edit for the post – DirtyNative Feb 04 '20 at 10:11
  • You can use [`AssemblyResolve`](https://learn.microsoft.com/en-us/dotnet/api/system.appdomain.assemblyresolve?view=netframework-4.8#remarks) event to load the satellite assembly from any location. It works starting from .NET 4. I can convert it into the answer, if it helps – Pavel Anikhouski Feb 04 '20 at 10:13
  • This [thread](https://stackoverflow.com/questions/4368201/appdomain-currentdomain-assemblyresolve-asking-for-a-appname-resources-assembl) might be helpful – Pavel Anikhouski Feb 04 '20 at 10:21

0 Answers0