Web Design that taps into the haromny and vision of your dreams.

Creating and Implementing Satellite Assemblies

What are Satellite Assemblies and what are they used for?

Written By on in C#

478 words, estimated reading time 3 minutes.

If you plan on localising your application (making your application customisable for different languages and cultures) you should use satellite assemblies and neutral code.

Using Visual Studio Series
  1. Getting Started with Visual Studio
  2. Using the Visual Studio Integrated Development Environment
  3. Using the Visual Studio Debugger
  4. XML Documentation in Visual Studio
  5. Using Microsoft .Net Command Line Tools
  6. What is an Assembly in Microsoft .Net?
  7. Creating and Using a .NET Assembly in C#
  8. Creating and Implementing Satellite Assemblies
  9. Creating Strong Named Assemblies in Microsoft .Net
  10. Visual Studio Task List
  11. Resources and Localisation in C# Projects
  12. Localising Microsoft .Net Applications with C#
  13. Using Resource Files in C# Applications
  14. Using XSD Tool to Generate Classes from XML
  15. 10 Visual Studio Tools You May Not Know About

Neutral code does not contain any hard coding or language/culture specific code. For example, there is no hardcoded strings or symbols, no hard coded date formatting and no region specific calculations e.g. VAT.

When creating a satellite assembly you should work with the naming convention suggested by Microsoft, The format of which is ..resource where the culture identifier consists of ISO language and culture strings. You can find a list of culture codes in this list List of .Net Culture Codes.

Satellite assemblies use a hub and spoke design, with your neutral code at the centre (hub) and various culture-specific satellite assemblies plugging into it (spokes). As a result, the runtime requires that you place resources in specific locations so that they can be easily located and used. If you do not compile and name resources as expected, or if you do not place them in the correct locations, the common language runtime will not be able to locate them. The compiler will first look in the global assembly cache for any localised satellite assemblies if it does not find any it will look in the following locations:

  1. The global assembly cache for an assembly matching the requested culture for the application
  2. The directory of the currently executing assembly for a directory matching the requested culture.
  3. The global assembly cache again, this time for the parent assembly of the requested resource.
  4. The runtime next checks the directory of the currently executing assembly to see if it contains a parent directory. If a parent directory exists, the runtime searches the directory for a valid satellite assembly for the parent culture.
  5. The runtime next searches parent assemblies, as in the previous step, through many potential levels.
  6. If a resource is not found then the default culture is used.

Creating Satellite Assemblies

By definition, satellite assemblies can only contain resources. They cannot contain any executable code. Satellite assemblies are compiled from resource files which can be added to a project from the add new item menu.

Resource files can be directly compiled into the executable, however, for the purposes of scalability, a satellite assembly allows new cultures and languages to be added without recompilation or distribution. Satellite assemblies can be used so that client downloads and installs a common executable and the just downloads and installs one satellite assembly for their location.

Satellite assemblies are created using the Assembly Linker (al.exe) command line tool.

Use the following command to create a satellite assembly for the application TestApp from the file strings.ja-JP.resources

static ResourceManager rm = new ResourceManager("strings", Assembly.GetExecutingAssembly());

This line of code will load the strings resource file from the assembly created above, assuming that ja-JP is the current system locale.

You can access or modify the current culture using the CultureInfo class:

CultureInfo ci = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentUICulture = en.US;

Last updated on: Thursday 22nd June 2017

 

Comments
nathan

nathan

I had this, make sure your DEFAULT NAMESPACE is not set to something different from where you used it.. as the resource automatically gains the default namespace!

Reply to nathan
Arun G

Arun G

It shows the following error

An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll

Additional information: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "ConfigSettingCulture.strings.en.resources" was correctly embedded or linked into assembly "ConfigSettingsCulture" at compile time, or that all the satellite assemblies required are loadable and fully signed.

Why this is happening ?
please reply.....

Regards,
Arun G

Reply to Arun G

 

Leave a Reply

Your email address will not be published.





If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.

Copyright © 2001-2018 Tim Trott, all rights reserved. Web Design by Azulia Designs

This web page is licensed for your personal, private, non-commercial use only.

Disclaimer, Privacy & LegalSitemapContact Me