Home United States USA — software Importing multiple extension assemblies in C# with MEF

Importing multiple extension assemblies in C# with MEF

118
0
SHARE

Array
An application rarely depends on one single extension. If it does, then it has something wrong with its extension model and maybe it doesn’t need one after all. An extensible application allows the use of a multiple extensions that satisfy the standard exposed by the SDK:
In my previous article I showed how to use MEF to import a single external assembly. However, MEF doesn’t impose a limit on the number of assemblies that can be imported, although some conventions should be followed.
The extension standard is defined by a single class library with the following contents:
I will create two new class libraries that will represent two different extensions for the base application. For the first extension, the implementation will be:
Here, I am implementing the IWriter interface and exporting the main class that will later on be used by the main application.
The second extension is implemented the same way, with minor naming changes and it displays a different message:
Now let’s look at the application itself, that will consume the extensions above.

Continue reading...