Pergunta

I am having an issue getting the correct resource file entries and need some help ... here is my scenario

I have a series of projects that are a part of a large reporting solution that follow this format

Plugin.****Report

  • Reference (folder)
  • DataAccessLayer (folder)
  • DataSets (folder)
  • DataWrappers (folder)
  • Localization (folder)

    *.cs

Where * is the name of the report I am going to generate

The *.cs has an export statement so that I can pick it up using MEF (not sure if this is relevant, but thought it worth mentioning). The namespace in *.cs is CompanyName.DataShaper.Plugin.*Report. Due to the project name, and location of the files, I changed the default namespace for each project to be CompanyName.DataShaper.Plugin.*Report (it was just Plugin.*Report before my change).

Now for the problem .. inside of *.cs I am instantiating a ResourceManager. That looks like this ...

_resourceManager =
                new ResourceManager("CompanyName.DataShaper.Plugin.*Report.Localization.*Report",
                    Assembly.GetExecutingAssembly());

inside my resx designer file I have the following ...

internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CompanyName.DataShaper.Plugin.*Report.Localization.*Report", typeof(*Report).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }

My call to the resource manager looks like this ...

string resourceString = _resourceManager.GetString(resourceKey, _currrentCultureInfo);

where _currentCultureInfo is a a correct CultureInfo object.

I have 4 different resx files in my Localization folder for each project, (****Report.resx, ****Report.fr-ca.resx, ****Report.en-gb.resx, ****Report.de-de.resx).

When I make the call to the resource manager, I always get the entry from the .resx ... never any of the other language files, regardless of the CultureInfo object I pass into the call. What have I messed up?

--> Quick update to my original question, but this does appear to be MEF related. I instantiated my class the old fashioned way (new *Report()) and made the localization call and it works fine

Foi útil?

Solução

OK, I figured this out .. I am getting the .resx file because it is truly embedded into the main assembly. The other files are getting built into separate dlls for each language, I then need to copy them into the same folder that I build my aggregate container from, my resource manager then sees all languages.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top