Introduction to Satellite Assemblies

A satellite assembly is a compiled library (DLL) that contains (“localizable”) resources such as strings, bitmaps, etc. You are likely to use them when creating a multilingual (UI) application. Satellite assemblies provide you with the capability of designing and deploying your solution to multiple cultures, rather than hard coding strings, bitmaps, etc., into your main application. Satellite assemblies are used to deploy applications in multiple cultures (not languages), with 1 satellite assembly per culture - this is the default behavior, but you can obviously have more granular control if you handle the build process manually.

By definition, satellite assemblies do not contain code, except for that which is auto generated. Therefore, they cannot be executed as they are not in the main assembly. However, note that satellite assemblies are associated with a main assembly that usually contains default neutral resources (for example, en-US). A big benefit is that you can add support for a new culture or replace/update satellite assemblies without recompiling or replacing the application’s main assembly.

Resource files have the extension .resx and are stored in folders matching the culture. Once compiled, .resources files are created. These are binary representations of the .resx files. Once the satellite assembly is generated, the resources will be stored in a .dll file.

For example:

The ResourceManager class allows applications to load resources from the satellite assemblies, and the default behavior is that it does so according to the CurrentUICulture setting. Note that the culture can only be known at runtime. If the application cannot find the desired resources, the fallback process will find the appropriate resources by searching the hierarchy of cultures looking for an appropriate fallback resource that most closely matches the request.

You can use the Language property in the Windows Form designer to trigger the generation of non-default cultures via .resx files. For example:

To associate a culture with the default binary resource, you need to set the NeutralResourcesLanguageAttribute property in the AssemblyInfo file (this file is automatically generated and contains the build information for the project).                                                                                

To create satellite assemblies, use al.exe (Assembly Linker) to compile .resources files into satellite assemblies (Note: .resx, .resource files are generated by the IDE; al.exe generates the .dll file(s)).

 

You may also use MSBuild. If your application is configured to generate a neutral-language-resources satellite assembly, MSBuild will generate the main application assembly, as well as the neutral-language-resources satellite assembly that is required for localization.

 

Another alternative is to use resgen.exe, which gets installed with the Windows SDK, and does the following:

  • Converts .txt or .restext files to .resources or .resx files
  • Converts .resources files to text or .resx files
  • Converts .resx files to text or .resources files

 

If your plan does not involve localization and you still want to embed resources (e.g. image files) into an assembly, set the Build Action property to "Embedded Resource" by

  1. a.     Adding the image file by right-clicking in the Solution Explorer -> Add Existing Item
  2. b.     In Properties, set the Build Action property to Embedded Resource

 

Follow these steps to compile satellite assemblies.

 

During deployment, the satellite assemblies will be placed in folders matching the name of the culture containing the assembly.

I hope this gives you a fair explanation of what satellite assemblies are, how they are used, and when they should be used. In a later post, I will show how to access the resources in the satellite assemblies.