Getting started with Multifile assembly
What is Multi-file assembly?
It is an application assembly either web-based or desktop-based which spans across many files to support extensibility and dynamically adding new features.
What is Modules?
Modules means class files such as Program.cs or frmMain.cs, in context of assemblies.
Usage of Multi-file assembly
- Using different modules written in different .NET based programming languages such as C#.NET and VB.NET .
- To optimize an application by putting less used types in a module that is loaded only as when needed or required i.e [Lazy-loading] (Note: The original article is no longer available online) assemblies.
- Reduce application start-up by loading only required assemblies at start-up and then load less used assemblies in background thread or parallel Task-based threads.
- Extend the application features by implementing plugin-based architecture, like we have in Orchard CMS and [NopCommerce] (Note: The original article is no longer available online) for [web-based applications] (Note: The original article is no longer available online) and in [StockTrader] (Note: The original article is no longer available online) desktop applications, Silverlight Rich Internet Applications (RIAs), and Windows Phone 7 applications.") application for desktop-based applications.
- We can incrementally release application features or fix a bug & release a patch without completely recompiling the main assembly or application.
- For multi-language applications releasing new languages support via custom language module packages.
Conceptual example of Multi-file assembly
For example, you have an [e-commerce] (Note: The original article is no longer available online) web application at hand which supports online booking goods & payments also, you currently have an account in [PayPal] (Note: The original article is no longer available online) so you create a main package containing Payment related interfaces and then reference it back to main application and in package which will be containing the actually concrete classes for [PayPal] (Note: The original article is no longer available online) implementation. And then plan and release new packages with more payment gateways such as [Authorize.NET] (Note: The original article is no longer available online) at later stage. This is a working example and implemented in [NopCommerce] (Note: The original article is no longer available online) web application. PS: I will come with a demonstration application for building real plugin-based applications in my future posts.
Advantages of Multi-file assembly
- [Desktop Application] (Note: The original article is no longer available online) with plug & play architectures are benefited.
- Change of application behavior or add more services at later stage in spiral [SDLC] (Note: The original article is no longer available online) model.
- More number of developers can work concurrently on larger projects independently on assigned modules.
- Supports agile application development approach.
- Complex projects can be built easily by [Separation Of Concerns] (Note: The original article is no longer available online).
Disadvantages of Multi-file assembly
- Increases development time as developers need to write without being aware of the main application and needs to communicate with various teams while integrating as a whole.
- Small-scale projects do not get its benefit as it would increase cost of development and time both.
Detailed steps to create and use multi-file assemblies can be found at AspAlliance.com article [here] (Note: The original article is no longer available online) and you can download sample from AspAlliance.com [MultifileAssembly.zip] (Note: The original article is no longer available online)
I would like if you would share your thoughts on this topic with me.
Thanks.
[Importing multiple extension assemblies in C# with MEF] (Note: The original article is no longer available online) Building a Multifile Assembly on MSDN Managed Extensibility Framework