# 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](http://msdn.microsoft.com/netframework ".NET Framework") based programming languages such as [C#.NET](http://msdn2.microsoft.com/en-us/vcsharp/aa336809.aspx "C Sharp (programming language)") 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 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](http://www.orchardproject.net/ "Orchard is a free, open source, community-focused project aimed at delivering applications and reusable components on the ASP.NET platform. ") CMS and NopCommerce for web-based applications and in StockTrader 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 web application at hand which supports online booking goods & payments also, you currently have an account in PayPal 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 implementation. And then plan and release new packages with more payment gateways such as Authorize.NET at later stage. This is a working example and implemented in NopCommerce 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 with plug & play architectures are benefited.
- Change of application behavior or add more services at later stage in spiral SDLC 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.

## 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 and you can download sample from AspAlliance.com MultifileAssembly.zip

I would like if you would share your thoughts on this topic with me.

Thanks.

 

Importing multiple extension assemblies in C# with MEF [Building a Multifile Assembly on MSDN]( http://msdn.microsoft.com/en-us/library/168k2ah5\(v=vs.71\) " http://msdn.microsoft.com/en-us/library/168k2ah5(v=vs.71)") [Managed Extensibility Framework]( http://mef.codeplex.com/ "The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.")

[CodeProject](http://www.codeproject.com)
