Endjin - Home

Using the endjin composition framework in an MVC application

by Mike Larah

As I was setting up the framework for my apprenticeship portal MVC 4 web application, I used part of endjin’s core composition framework for the dependency injection, which utilises Castle Windsor.

(Here is a link to some useful videos on dependency injection and Castle Windsor that helped me to understand why they are used).

Part of the framework uses a class called WindsorContainerBootstrapper which calls a GetInstallers method which looks through all referenced assemblies and finds and returns a list of the Windsor Installers that are contained within them.

This was designed for console applications though. To make this work, I made a change so that it uses the HttpRuntime.BinDirectory method to correctly locate the bin folder where the assemblies are stored in a web application.

This extra class could not be added to Endjin.Core.Composition though as HttpRuntime is dependent on System.Web, and Endjin.Core.Composition uses the .NET 4 Client Profile which does not support this.

So I added a new WindsorContainerWebBootstrapper class to the project and called it in the dependency injection configuration to initialise a new Windsor Container.

This means I can now resolve my types dynamically.

(As a side note, we now have a GitHub Gist plugin installed for the blog so all the pasted code looks pretty)


About the author

Mike is a Software Engineer at endjin with 4 years experience in solving technology problems for clients. He is a certified Microsoft Cloud Platform developer, and has experience building solutions utilising much of the Azure ecosystem.