Search code examples
c#resources.net-assemblyresxbuildconfiguration

Resources in a separate assembly not visible in different build configurations


I have a problem with resources with localizations in web application. I need to use them from different assemblies (WebSite, BLL, etc.) so I decided to move them to a separate library. I'm using three different build configurations (Debug, Release and QA which is based on Release). When I run the application locally everything is fine (independently from configuration). The problem is when I deploy it on IIS (same situation for local or external server). Deployment in Debug configuration works fine but in QA or Release I get this exception:

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyToolResources.Resources.Emails.Mail.resources" was correctly embedded or linked into assembly "BusinessLogicLayer" at compile time, or that all the satellite assemblies required are loadable and fully signed.

I found many topics with that problem but none of them was depending on build / deployment configuration.

Assemblies: MyTool - web site BusinessLogicLayer - class library MyToolResources - class library with resources

My resource manager:

var assembly = System.Reflection.Assembly.GetCallingAssembly();
mailResourceManager = new ResourceManager("MyToolResources.Resources.Emails.Mail", assembly);

private static ResourceSet GetResourceSet(ResourceManager resourceManager, CultureInfo culture)
{
    return resourceManager.GetResourceSet(culture, true, true);
}

The assembly with resources is correctly copied into /bin directory - same in Debug and QA/Release configurations.


Solution

  • After comparing both IIS configurations I have finally found the solution. Build for deployment has to be explicitly targeted to x86 (even for x64 environment) and then it works.