Search code examples
c#.netdllsatellite-assembly

Use satellite assemblies from another dll


I have a dll which contains some resx files as EmbeddedResources for the localization. That dll is used mostly for the creation of ASP.NET websites and it's worked fine.

But when I use the dll in my test project (basically that's just another dll), I can't have access to the satellite assemblies content, for example I can't access to the English translation of my messages. It return only the fallback messages.

Code used :

ResourceManager _resourceManager = new ResourceManager(baseName, Assembly.GetExecutingAssembly());
_resourceManager.GetString(key, cultureInfo);

baseName is the fully qualified name of the resource, for example: myNamespace.MyResourceName.

I'm thinking that it's the loading of the dll which is different when the project is a dll or a website, but I don't know how to load it correctly.

Anyone have an idea or a tip?

Thanks.

Edit: I have the dll A with some resx:

  • Messages.resx
  • Messages.en.resx
  • Messages.de.resx
  • etc...

At the end of the build, it generates some dlls:

  • A.dll
  • en/A.resources.dll
  • de/A.resources.dll
  • etc...

If the dll A is referenced by a website, the website can have access to the localized resource, like a message in en or de. But if it's another dll like my unit tests dll which references the dll A, it's always the fallback messages which are returned.


Solution

  • It appears that the problem coming from the use of the ResourceManager in the unit test, the languages folder aren't copied in the base folder used by the unit tests, see this question: ResourceManager.GetString fails in unit tests.