Partager via


How to: Dynamically Load Modules

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Overview

This topic describes how to dynamically load modules. When you load a module dynamically, the Shell does not contain a reference to the module's assembly; instead, modules are dynamically discovered when the application starts. By doing this, the Shell is decoupled from the modules. This implies that you can add, update, or remove modules from your application without recompiling the Shell.

Dynamic module loading requires a module's discovering and loading process to be executed on startup that may result in reduced startup performance compared to static module loading. In cases where decoupling modules from the Shell is not a requirement, you should consider static module loading, because it can reduce code complexity, simplify the application deployment, improve startup performance, and simplify debugging compared to dynamic loading.

The Composite Application Library provides two different mechanisms to dynamically discover modules. You can use either one, depending on your requirements and coding conventions. The following are the two ways that you can dynamically discover modules:

  • Directory lookup. This mechanism, implemented in the DirectoryLookupModuleEnumerator class, discovers modules in assemblies stored in a particular folder. This approach requires you to configure modules using attributes in code and does not require a configuration file. For detailed instructions on how to use this mechanism, see Using the Directory Lookup Module Enumerator.
  • Configuration. This mechanism, implemented in the ConfigurationModuleEnumerator class, discovers modules by reading the configuration file of the application. This approach requires a configuration file and does not require you to use attributes in code. For detailed instructions on how to use this mechanism, see Using the Configuration Module Enumerator.

Note

This topic assumes that you are familiar with modules. For more information, see the Modules technical concept.

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.